Submission

Status:

PPPPP

Subtask/Task Score:

100/100

Score: 100

User: nemuchannnUwU

Problemset: ชั้นหนังสือ

Language: cpp

Time: 0.027 second

Submitted On: 2025-10-20 16:38:26

#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int L,N;
    vector<string> v;
    cin >> L >> N;
    for (int i=0;i<N;i++){
        int n;
        cin >> n;
        string a;
        cin >> a;
        for (int j=0;j<n;j++){
            v.push_back(a);
        }
    }
    sort(v.begin(),v.end());
    int len=v.size();
    for (int i=0;i<len*2+1;i++){
        if (i%2==0) cout << "+";
        else cout << "-";
    }
    cout << "\n";
    int cnt_unflipped=0;
    int cnt_flipped=L-1;
    for (int i=0;i<L;i++){
        int cnt=0;
        for (int j=0;j<len*2+1;j++){
            if (j%2==0) cout << "|";
            else{
                if (v[cnt].size()-1>=cnt_unflipped&&cnt%2==0){
                    cout << v[cnt][cnt_unflipped];
                    cnt++;
                }else if (v[cnt].size()-1>=cnt_flipped&&cnt%2==1){
                    cout << v[cnt][cnt_flipped];
                    cnt++;
                }else{
                    cout << ".";
                    cnt++;
                    }
            }
        }
        cnt_unflipped++;
        cnt_flipped--;
        cout << "\n";
    }

    for (int i=0;i<len*2+1;i++){
        if (i%2==0) cout << "+";
        else cout << "-";
    }
}