Submission
Status:
PP---
Subtask/Task Score:
40/100
Score: 40
User: rice_ot
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.026 second
Submitted On: 2025-10-17 09:49:23
#include <bits/stdc++.h>
using namespace std;
int main(){
int l, n; cin>>l>>n;
if(l < 1 || l > 30 || n < 1 || n > 2000) return 0;
map<string, int> book;
int range = 0;
for(int i = 0; i<n; i++){
int a; string x; cin>>a>>x;
book[x] = a;
range+=a;
}
//done input
vector<vector<char>> grid(l, vector<char>(range, '.'));
int index = 0;
for(auto& i : book){
int quantity = i.second;
string name = i.first;
for(int j = 0; j<quantity; j++){
if(index%2 == 0){ //up to down
for(int k = 0; k<name.length(); k++){
grid[k][index] = toupper(name[k]);
}
}
else{ //down to up
for(int k = 0; k<name.length(); k++){
grid[l-1-k][index] = toupper(name[k]);
}
}
index++;
}
}
for(int i = 0; i<range*2+1; i++){
if(i%2 == 0) cout<<"+";
else cout<<"-";
}
cout<<"\n";
for(int i = 0; i<l; i++){
cout<<"|";
for(int j = 0; j<range; j++){
cout<<grid[i][j]<<"|";
}
cout<<"\n";
}
for(int i = 0; i<range*2+1; i++){
if(i%2 == 0) cout<<"+";
else cout<<"-";
}
cout<<"\n";
}