QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586397#9114. Black or White 2pengpeng_fudanWA 161ms3744kbC++232.9kb2024-09-24 11:58:492024-09-24 11:58:50

Judging History

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

  • [2024-09-24 11:58:50]
  • 评测
  • 测评结果:WA
  • 用时:161ms
  • 内存:3744kb
  • [2024-09-24 11:58:49]
  • 提交

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&&k;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: 100
Accepted
time: 0ms
memory: 3736kb

input:

2
2 2 2
2 3 0

output:

10
01
000
000

result:

ok Output is valid. OK.

Test #2:

score: -100
Wrong Answer
time: 161ms
memory: 3744kb

input:

27520
2 2 0
2 2 1
2 2 2
2 2 3
2 2 4
2 3 0
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
3 2 0
3 2 1
3 2 2
3 2 3
3 2 4
3 2 5
3 2 6
3 3 0
3 3 1
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
3 3 8
3 3 9
2 4 0
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
2 4 7
2 4 8
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10...

output:

00
00
10
00
10
01
01
11
11
11
000
000
100
000
100
001
110
100
011
110
011
111
111
111
00
00
00
10
00
00
10
00
01
11
10
00
01
11
10
01
11
11
11
11
11
000
000
000
100
000
000
101
000
000
101
000
100
101
000
101
111
111
111
110
111
010
011
111
011
011
111
111
111
111
111
0000
0000
1000
0000
1000
0001
1...

result:

wrong answer The number of black cell is not K