QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#483289#9114. Black or White 2ucup-team1525#WA 159ms4004kbC++201.8kb2024-07-18 15:05:262024-07-18 15:05:27

Judging History

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

  • [2024-07-18 15:05:27]
  • 评测
  • 测评结果:WA
  • 用时:159ms
  • 内存:4004kb
  • [2024-07-18 15:05:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,m,k;
const int N=1505;
int a[N][N];
// int n,m,k;
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 (k>=2*n)
    {
        int p=(k-(n+1)/2)/n+1;
        int sum=p*n+(n+1)/2;
        for (int i=1;i<=n;++i)
            for (int j=1;j<=p;++j)
            {
                a[i][j]=1;
                if (sum>=k&&i%2==1&&j%2==1)
                {
                    --sum;
                    a[i][j]=0;
                }
            }   
        for (int i=1;i<=n;++i)
            if (i%2==1)
                a[i][p+1]=1;
    }
    else
    {
        for (int i=1;i<=n;++i)
            for (int j=1;j<=m;++j)
                if (i%2==1&&j%2==1&&k!=0)
                {
                    --k;
                    a[i][j]=1;
                }
        for (int i=1;i<=n;++i)
            for (int j=1;j<=m;++j)
                if (a[i][j]==0&&k!=0)
                {
                    --k;
                    a[i][j]=1;
                }
    }
    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()
{
    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: 3988kb

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: 159ms
memory: 4004kb

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
111
000
010
111
011
111
111
111
00
00
00
10
00
00
10
00
10
10
10
10
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.