QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586394#9114. Black or White 2pengpeng_fudanWA 0ms3824kbC++232.9kb2024-09-24 11:58:052024-09-24 11:58:06

Judging History

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

  • [2024-09-24 11:58:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-09-24 11:58:05]
  • 提交

answer

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

void solve(void) {
    int n,m,k;
    cin>>n>>m>>k;
    bool flag=(n>m);
    if(n>m) swap(n,m);
    vector<vector<bool>> ans(n+1,vector<bool>(m+1));
    if(n==2){
        if(k==1){ans[1][1]=1;k--;}
        else if(k==2)   {ans[1][1]=ans[n][m]=1;k-=2;}
        else{
            for(int i=2;i<=m;i++){
                if(k==1){ans[1][1]=1;k--;break;}
                ans[1][i]=ans[2][i-1]=1;k-=2;
            }
            if(k)   {ans[n][m]=1;k--;}
            if(k)   {ans[1][1]=1;k--;}

        }       
    }
    else{
        if(k==0);
        else if(k==1){
            ans[1][1]=1;
        }
        else if(k==2){
            ans[1][1]=ans[1][n]=1;
        }
        else if(k==3){
            ans[1][1]=ans[1][m]=ans[n][1]=1;
        }
        else if(k==4){
            ans[1][1]=ans[1][m]=ans[n][1]=ans[n][m]=1;
        }
        else{
            ans[2][1]=ans[1][2]=ans[2][2]=ans[2][3]=ans[3][2]=1;
            k-=5;
            int x=3;
            while(x+1<=n){
                if(k==1)    {ans[1][1]=1;k--;break;}
                if(k==2)    {ans[1][1]=ans[1][n]=1;k=0;break;}
                ans[x+1][x]=ans[x][x+1]=ans[x][x]=1;k-=3;
                x++;
            }
            if(k==1){ans[1][1]=1;k=0;}
            else if(n==m){k--;ans[n][n]=1;}
            else if(k>=2){ans[n][n]=ans[n][n+1]=1;k-=2;}
            x=1;int y=3;int lo=3;
            while(k){
                if(y+1<=m){
                    if(k==1) {ans[1][1]=1;k--;break;}
                    else {ans[x][y]=ans[x][y+1]=1;k-=2;}
                }
                else if(y<=m){
                    ans[x][y]=1;k--;
                }
                if(x==1)    lo+=2;
                if(x==n)    {
                    x=1,y=lo;
                    if(lo>m)    break;
                }
                else x++,y++;
            }


            x=3,y=1;lo=3;
            while(k){
                if(x+1<=n){
                    if(k==1) {ans[1][1]=1;k--;break;}
                    else {ans[x][y]=ans[x+1][y]=1;k-=2;}
                }
                else if(x<=n){
                    ans[x][y]=1;k--;
                }
                if(y==1)    lo+=2;
                if(y==n)    {
                    y=1,x=lo;
                    if(lo>n)    break;
                }
                else x++,y++;
            }
        }
        if(k)   ans[1][1]=1;
    }
    if(flag){
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++)   cout<<ans[j][i];
            cout<<'\n';
        }
    }
    else{
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++)   cout<<ans[i][j];
            cout<<'\n';
        }
    }


}

int main() {
    // ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    int _ = 1;
    cin >> _;
    while (_--) solve();

    return 0;
}

/*
UTCUCUCUCUPC
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3824kb

input:

2
2 2 2
2 3 0

output:

10
01
111
111

result:

wrong answer The number of black cell is not K