Submission

Status:
-P----P-P-

Score: 30

User: Mingyuanz

Problemset: G.Peach's Backpack

Language: cpp

Time: 0.718 second

Submitted On: 2024-10-13 22:53:25

#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
#define INF (int)1e9
#define MOD (int)(1e9+7)
#define MAXN 200005
#define enl '\n'
//#define int long long
typedef long long ll;
using namespace std;
void testcase(){
    int n,m,q,now=0,x,y,k;
    cin >> m >> n >> q;
    char arr[n][m];
    for(int i=0; i<n; i++) for(int j=0; j<m; j++) arr[i][j]='.';
    vector<int> ans;
    for(int t=0; t<q; t++){
        cin >> y >> x >> k; // [x][y]
        k--;
        int mn=n;
        if(k+y>m){
            ans.pb(t);
            goto cont;
        }
        for(int i=k; i<k+y; i++){
            for(int j=0; j<n; j++){
                if(arr[j][i]!='.'){
                    mn=min(mn,j);
                    break;
                }
            }
        }
        if(mn>=x){
            int a=mn-x,b=k;
            for(int i=0; i<x; i++) for(int j=0; j<y; j++){
                arr[a+i][b+j]='A'+((now++)%26);
            }
        } else{
            ans.pb(t);
        }
        cont:;
    }
    for(auto v: ans) cout << v+1 << " ";;
    cout << enl;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++) cout << arr[i][j];
        cout << enl;
    }
}
signed main(){
    ios_base::sync_with_stdio(true);
    cin.tie(0);
    int t=1;
    while(t--){
        testcase();
    }
    return 0;
}

/*

5 3
4
1 1 4
3 2 2
1 2 3
1 2 1


*/

/*
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
#define INF (int)1e9
#define MOD (int)(1e9+7)
#define MAXN 2004
#define MAXS 20004
#define enl '\n'
typedef long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(true);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int arr[n];
        for(int i=0; i<n; i++) cin >> arr[i];
    }
    return 0;
}
*/