Submission
Status:
PP---
Subtask/Task Score:
40/100
Score: 40
User: echo1faust
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.023 second
Submitted On: 2025-06-08 20:29:30
#include<bits/stdc++.h>
using namespace std;
void line(int column){
cout << '+';
for(int i=0;i<column;i++){
cout << "-+";
}
cout << '\n';
}
int main(){
cin.tie(0)->sync_with_stdio(0);
int row,N;
cin >> row >> N;
map<string,int> books;
int column = 0;
for(int i=0;i<N;i++){
int Ki;
string Si;
cin >> Ki >> Si;
books[Si] = Ki;
column += Ki;
}
vector<vector<char>> bookshelf(row,vector<char>(column,'.'));
int current_column = 0;
for(auto &[name,amount] : books){
int length = name.size();
for(int t=0;t<amount;t++){
if(current_column % 2 == 0){
for(int current_row = 0;current_row < length; current_row++){
bookshelf[current_row][current_column] = name[current_row];
}
}
else{
for(int current_row = row - 1; current_row >= row - length ;current_row--){
bookshelf[current_row][current_column] = name[row - 1 - current_row];
}
}
current_column += 1;
}
}
line(column);
for(int i = 0;i<row;i++){
cout << '|';
for(int j=0;j<column;j++){
cout << bookshelf[i][j] << '|';
}
cout << '\n';
}
line(column);
return 0;
}