Submission
Status:
-----
Subtask/Task Score:
0/100
Score: 0
User: 38408
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.023 second
Submitted On: 2026-10-15 02:59:13
#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++) {
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";
}