Submission
Status:
PPPPP
Subtask/Task Score:
100/100
Score: 100
User: qweqwe
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.024 second
Submitted On: 2025-10-08 18:26:36
#include <bits/stdc++.h>
#define speed cin.tie(0)->sync_with_stdio(0)
#define ll long long
#define pii pair<int,int>
using namespace std;
int main(){
speed;
int n,l;cin >> l >> n;
vector<string> books;
int sum=0;
for (int i=0;i<n;i++){
int a;string b;cin >> a >> b;
sum+=a;
for (int j=0;j<a;j++){
books.push_back(b);
}
}sort(books.begin(),books.end());
int idx=0,idxx=0;
for (int i=0;i<sum;i++){cout << "+-";}cout << "+\n";
for (int i=0;i<l;i++){
for (int j=0;j<=2*sum;j++){
if (j%2==0) cout << "|";
else if (j%4==1){
if (i<books[j/2].size())cout << books[j/2][i];
else cout << ".";
}else if (j%4==3){
if ((l-i)<=books[j/2].size())cout << books[j/2][l-i-1];
else cout << ".";
}
}cout << "\n";
}for (int i=0;i<sum;i++){cout << "+-";}cout << "+";
return 0;
}