QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485092#9114. Black or White 2ucup-team1525WA 154ms4000kbC++142.4kb2024-07-20 12:24:462024-07-20 12:24:46

Judging History

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

  • [2024-07-20 12:24:46]
  • 评测
  • 测评结果:WA
  • 用时:154ms
  • 内存:4000kb
  • [2024-07-20 12:24:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,m,k;
const int N=1505;
int a[N][N];
void solve()
{
    scanf("%d%d%d",&n,&m,&k);
    int inv=0,trp=0;
    if (k>n*m/2)
    {
        k=n*m-k;
        inv=1;
    }
    if (n>m)
    {
        swap(n,m);
        trp=1;
    }
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j)
            a[i][j]=0;
    if (n==4&&m==4&&k==5)
    {
        a[1][2]=a[2][1]=a[2][2]=a[2][3]=a[3][2]=1;
    }
    else
    {
        if (k<n+(n+1)/2)
        {
            for (int i=1;i<=n;i+=2)
                for (int j=1;j<=m;j+=2)
                    if (k)
                    {
                        --k;
                        a[i][j]=1;
                    }
            for (int i=1;i<=n;++i)
                for (int j=1;j<=m;++j)
                    if (k&&a[i][j]==0)
                    {
                        --k;
                        a[i][j]=1;
                    }
        }
        else
        {
            for (int i=2;i<=m;++i)
                if (i*n+(n+1)/2>k)
                {
                    for (int j=1;j<=n;++j)
                        for (int l=1;l<i;++l)
                            a[j][l]=1;
                    for (int j=1;j<=n;j+=2)
                        a[j][i]=1;
                    k-=(i-1)*n+(n+1)/2;
                    for (int l=m;l>i;l-=2)
                        for (int j=1;j<=n;j+=2)
                            if (k)
                            {
                                --k;
                                a[j][l]=1;
                            }
                    break;
                }
        }
    }
    if (inv)
    {
        for (int i=1;i<=n;++i)
            for (int j=1;j<=m;++j)
                a[i][j]=!a[i][j];
    }
    if (trp)
    {
        for (int i=1;i<=m;++i)
        {
            for (int j=1;j<=n;++j)
                printf("%d",a[j][i]);
            puts("");
        }
    }
    else
    {
        for (int i=1;i<=n;++i)
        {
            for (int j=1;j<=m;++j)
                printf("%d",a[i][j]);
            puts("");
        }
    }
}
int main()
{
    // for (int i=2;i<=8;++i)
    //     for (int j=i;j<=8;++j)
    //         for (int k=0;k<=i*j;++k)
    //             prework(i,j,k,prea[i][j][k]);
    scanf("%d",&t);
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

2
2 2 2
2 3 0

output:

11
00
000
000

result:

ok Output is valid. OK.

Test #2:

score: -100
Wrong Answer
time: 154ms
memory: 4000kb

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

result:

wrong answer Output doesn't minimize loss.