Submission
Status:
PPPPP
Subtask/Task Score:
100/100
Score: 100
User: 38408
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.023 second
Submitted On: 2026-10-15 03:02:52
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,l;
cin >> l >>n;
vector<string>book;
for (int i = 0; i < n; i++)
{
int c;
string x ;
cin>>c>>x;
for(int j = 0; j<c;j++){
book.push_back(x);
}
}
sort(book.begin(),book.end());
for (int i = 0; i < book.size(); i++)
cout << "+-";
cout << "+\n";
for (int j = 0; j < l; j++) {
cout << "|";
for (int i = 0; i < book.size(); i++) {
int pos = j;
if (i % 2 != 0)
pos = l - 1 - j;
if (pos >= 0 && pos < book[i].size())
cout << book[i][pos] << "|";
else
cout << ".|";
}
cout << "\n";
}
for (int i = 0; i < book.size(); i++)
cout << "+-";
cout << "+\n";
}