Submission
Status:
PP---
Subtask/Task Score:
40/100
Score: 40
User: echo1faust
Problemset: ชั้นหนังสือ
Language: cpp
Time: 0.009 second
Submitted On: 2025-06-08 21:00:48
#include<bits/stdc++.h>
using namespace std;
string line(int column){
string outline = "+";
for(int i=0;i<column;i++){
outline += "-+";
}
return outline;
}
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(const 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 = 0; current_row < length ;current_row++){
bookshelf[row - 1 - current_row][current_column] = name[current_row];
}
}
current_column += 1;
}
}
vector<string> buffer;
buffer.emplace_back(line(column));
for(int i = 0;i<row;i++){
string str = "|";
for(int j=0;j<column;j++){
str += bookshelf[i][j];
str += "|";
}
buffer.emplace_back(str);
}
buffer.emplace_back(line(column));
for(const string& line : buffer){
cout << line << '\n';
}
cout << '\n';
return 0;
}