QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#485041 | #9114. Black or White 2 | ucup-team1525 | WA | 159ms | 3916kb | C++17 | 2.1kb | 2024-07-20 10:47:17 | 2024-07-20 10:47:17 |
Judging History
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 (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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 3916kb
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.