QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587939#9114. Black or White 2Mu_Silk#WA 1ms3780kbC++202.6kb2024-09-24 22:50:582024-09-24 22:50:58

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 22:50:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-09-24 22:50:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n,m,k;cin>>n>>m>>k;
    bool f=false;
    if(n>m)swap(n,m),f=true;
    vector<vector<int>> a(n+1,vector<int>(m+1));

    if(k==0);
    else if(n==2){
        if(k==1)a[1][1]=1;
        else if(k==2)a[1][1]=a[n][m]=1;
        else if(k==n*m)for(int i=1;i<=m;i++)a[1][i]=a[2][i]=1;
        else{
            for(int i=1;i<=k/2;i++)a[1][i+1]=a[2][i]=1;
            if(k%2==1)a[1][1]=1;
        }
    }
    else{
        if(k==1)a[1][1]=1;
        else if(k==2)a[1][1]=a[n][m]=1;
        else if(k==3)a[1][1]=a[n][m]=a[1][m]=1;
        else if(k==4)a[1][1]=a[n][m]=a[1][m]=a[n][1]=1;
        else{
            k-=5;
            a[1][2]=a[2][1]=a[2][2]=a[2][3]=a[3][2]=1;
            int cur=3;
            while(k>3){
                if(cur+1>n)break;
                a[cur][cur]=a[cur][cur+1]=a[cur+1][cur]=1;
                k-=3;
                cur++;
            }
            if(k==1){
                k-=1;
                a[1][1]=1;
            }
            if(k>=2){
                a[cur][cur]=1;
                k--;
                if(cur+1<=m)a[cur][cur+1]=1;
                k--;
            }
            int curx=1,cury=3;
            // cerr<<k<<"\n";
            while(k>1){
                a[curx][cury]=1;
                k--;
                if(cury+1<=m){
                    a[curx][cury+1]=1;
                    k--;
                }
                curx++,cury++;
                if(cury>m){
                    cury=cury-curx+3,curx=1;
                    if(cury>m)break;
                }
            }
            // cerr<<k<<"\n";
            curx=3,cury=1;
            while(k>1){
                a[curx][cury]=1;
                k--;
                if(curx+1<=n){
                    a[curx+1][cury]=1;
                    k--;
                }
                curx+=1,cury+=1;
                if(curx>n){
                    curx=curx-cury+3,cury=1;
                    if(curx>n)break;
                }
            }
            // cerr<<k<<"\n";
            if(k)a[1][1]=1;
        }
    }

    if(f){
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++)cout<<a[j][i]<<" ";
            cout<<"\n";
        }
    }
    else{
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++)cout<<a[i][j]<<" ";
            cout<<"\n";
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n=1;
    cin>>n;
    while(n--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3780kb

input:

2
2 2 2
2 3 0

output:

1 0 
0 1 
0 0 0 
0 0 0 

result:

wrong answer