Submission
Status:
PPPPP
Score: 100
User: Winzzwz
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.032 second
Submitted On: 2024-11-10 19:32:28
#include <bits/stdc++.h>
using namespace std;
vector<string> books;
int l,n;
bool cmp(string a, string b) {
return a < b;
}
/*
59 1
59 ABCD
*/
int main() {
//cin.tie(nullptr)->sync_with_stdio(false);
cin >> l >> n;
for (int i = 0; i < n; i++) {
int k;
string s;
cin >> k >> s;
for (int j = 0; j < k; j++) {
books.push_back(s);
}
}
int sz = books.size();
//cout << books.size();
sort(books.begin(),books.end(),cmp);
for (int i = 1; i <= 2*sz+1; i++) {
if (i%2 == 1) cout << '+';
else cout << '-';
}
cout << "\n";
for (int i = 0; i < l; i++) {
for (int j = 1; j <= sz; j++) {
int v = (j%2 == 1) ? i : l-i-1;
int nj = j-1;
if (j == 1) cout << '|';
if (v >= 0 && v < books[nj].size()) cout << books[nj][v];
else cout << '.';
cout << '|';
}
cout << '\n';
}
for (int i = 1; i <= 2*sz+1; i++) {
if (i%2 == 1) cout << '+';
else cout << '-';
}
return 0;
}
/*
15 4
1 AMOGUS
4 ILOVEPEEM
3 ILOVELUKNUT
5 VIEWEWEWEW
4 4
1 ABCD
1 DABC
1 BCDA
1 CDAB
*/