QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#476105 | #9114. Black or White 2 | ucup-team3510# | WA | 40ms | 5888kb | C++20 | 2.1kb | 2024-07-13 17:53:08 | 2024-07-13 17:53:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,c;char s[2011][2011],t[2011][2011];bool flg;
int a[2011];
void print()
{
if(c%2!=k%2)s[1][1]='0',--c;
if(flg)
{
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)t[j][i]=s[i][j];
for(int i=1;i<=m;++i)t[i][n+1]=0;
for(int i=1;i<=m;++i)printf("%s\n",t[i]+1);
}
else
{
for(int i=1;i<=n;++i)s[i][m+1]=0;
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
}
}
int main()
{
scanf("%d",&T);while(T--)
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;++i)s[i][m+1]=0;
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]='0';
if(k==0)
{
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
continue;
}
if(k==1)
{
s[1][1]='1';
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
continue;
}
if(k==3)
{
s[1][1]=s[1][2]=s[2][1]='1';
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
continue;
}
if(n==2&m==2)
{
int cc=0;
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
{
++cc;if(cc<=k)s[i][j]='1';
}
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
continue;
}
flg=0;
if(m==2)
{
flg=1,swap(n,m);
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]='0';
}
c=0;
for(int i=1;i<=m;++i)a[i]=0;
for(int i=1;i<=m;i+=2)
{
a[i]=1;
s[1][i]='1';++c;
if(c>=k)break;
for(int j=i-1;j;--j)
{
if(a[j]+2<=n)
{
c+=2;
s[a[j]+1][j]=s[a[j]+2][j]='1';
a[j]+=2;
if(c>=k)break;
}
else if(a[j]+1<=n)
{
++c;
s[a[j]+1][j]='1';
a[j]+=1;
if(c>=k)break;
}
}
if(c>=k)break;
}
// for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
// printf("c:%d\n",c);
if(c>=k)
{
print();
}
else
{
while(1)
{
for(int j=m;j;--j)
{
if(a[j]+2<=n)
{
c+=2;
s[a[j]+1][j]=s[a[j]+2][j]='1';
a[j]+=2;
if(c>=k)break;
}
else if(a[j]+1<=n)
{
++c;
s[a[j]+1][j]='1';
a[j]+=1;
if(c>=k)break;
}
}
if(c>=k)break;
for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
printf("c:%d\n",c);
}
print();
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5852kb
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: 40ms
memory: 5888kb
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 11 10 11 11 000 000 100 000 101 000 110 100 111 010 111 110 111 111 00 00 00 10 00 00 10 00 10 11 10 00 10 11 10 11 11 10 11 11 11 000 000 000 100 000 000 101 000 000 110 100 000 111 010 000 011 110 100 111 110 100 011 111 101 111 111 101 111 111 111 0000 0000 1000 0000 1010 0000 1...
result:
wrong answer The number of black cell is not K