QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#475142 | #9114. Black or White 2 | ucup-team052# | WA | 150ms | 5992kb | C++23 | 1.6kb | 2024-07-13 11:40:55 | 2024-07-13 11:40:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 1505
int ans[N][N],tmp[N][N],n,m,k,op,op2;
void work()
{
n=read(),m=read(),k=read();
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[i][j]=0;
op=op2=0;
if(k>n*m/2) op=1,k=n*m-k;
if(n==2&&m==2)
{
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(k) ans[i][j]=1,k--;
}
else
{
if(m<n) swap(n,m),op2=1;
int rst=(n+1)/2;
if(k<=rst)
{
for(int i=1;i<=n;i+=2) if(k) ans[i][1]=1,k--;
}
else
{
int wl=(k-rst)/n;
for(int j=1;j<=wl;j++) for(int i=1;i<=n;i++) ans[i][j]=1,k--;
for(int i=1;i<=n;i+=2) ans[i][wl+1]=1,k--;
for(int i=1;i<=n;i+=2) if(k) ans[i][m]=1,k--;
for(int i=1;i<=n;i+=2) if(k) ans[i][m-2]=1,k--;
}
if(op2)
{
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) tmp[i][j]=ans[i][j];
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[j][i]=tmp[i][j];
swap(n,m);
}
}
if(op)
{
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[i][j]^=1;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++) printf("%d",ans[i][j]);
printf("\n");
}
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5848kb
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: 150ms
memory: 5992kb
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 11 10 00 11 10 00 11 11 10 11 01 11 00 01 11 00 11 11 00 000 000 000 100 000 000 100 000 100 101 000 100 101 000 101 010 111 010 010 111 011 011 111 011 011 111 111 111 111 111 0000 0000 1000 0000 1001 0000 1...
result:
wrong answer The number of black cell is not K