10分其余wa 求调
查看原帖
10分其余wa 求调
731561
adc1313楼主2023/10/18 23:13
#include <bits/stdc++.h>
using namespace std;

const int N=1000010,M=100010;

struct color{
    int opt,x,c;
};

int T;
int n,m,q;
int a[N];
bool h[M],l[M];
bool flag[N];

stack<color>st;

void print(bool f,int idx,int c){
    if(!f){
        if(h[idx])return;
        for(int i=1;i<=m;i++){
            int j=m*(idx-1)+i;
            if(!flag[j]){
                a[j]=c;
                flag[j]=true;
            }
        }
        h[idx]=true;
    }else{
        if(l[idx])return;
        for(int i=0;i<=n;i++){
            int j=idx+i*m;
            if(!flag[j]){
                a[j]=c;
                flag[j]=true;
            }
        }
        l[idx]=true;
    }
}

void game(){
    while(st.size()){
        auto t=st.top();
        st.pop();
        print(t.opt,t.x,t.c);
    }
}

int main(){
    cin>>T;
    while(T--){
        memset(a,0,sizeof a);
        memset(h,false,sizeof h);
        memset(l,false,sizeof l);
        memset(flag,false,sizeof flag);
        while(st.size())st.pop();
        cin>>n>>m>>q;
        while(q--){
            int x,y,z;
            scanf("%d%d%d",&x,&y,&z);
            st.push({x,y,z});
        }
        game();
        for(int i=1,j=1;i<=n*m;i++,j++){
            printf("%d",a[i]);
            if(j==m){
                printf("\n");
                j=0;
            }
        }
    }
}

2023/10/18 23:13
加载中...