QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587973#9114. Black or White 2Mu_SilkRE 1ms3800kbC++202.5kb2024-09-24 23:10:082024-09-24 23:10:09

Judging History

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

  • [2024-09-24 23:10:09]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3800kb
  • [2024-09-24 23:10:08]
  • 提交

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+10,vector<int>(m+10));

    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&&cur==n){
                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++,cury++;
                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: 100
Accepted
time: 1ms
memory: 3800kb

input:

2
2 2 2
2 3 0

output:

10
01
000
000

result:

ok Output is valid. OK.

Test #2:

score: -100
Runtime Error

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
11
10
11
11
000
000
100
000
100
001
110
100
011
110
111
110
111
111
00
00
00
10
00
00
10
00
01
11
10
00
01
11
10
11
11
10
11
11
11
000
000
000
100
000
000
100
000
001
101
000
001
101
000
101
010
111
010
110
111
010
110
111
011
111
111
011
111
111
111
0000
0000
1000
0000
1000
0001
1...

result: