QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587981 | #9114. Black or White 2 | Mu_Silk | WA | 120ms | 3644kb | C++20 | 2.4kb | 2024-09-24 23:16:21 | 2024-09-24 23:16:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
int n,m,k;cin>>n>>m>>k;
bool f=false;
if(n>m)swap(n,m),f=true;
vector<vector<int>> a(n+10,vector<int>(m+10));
if(k==0);
else if(n==2){
if(k==1)a[1][1]=1;
else if(k==2)a[1][1]=a[n][m]=1;
else if(k==n*m)for(int i=1;i<=m;i++)a[1][i]=a[2][i]=1;
else{
for(int i=1;i<=k/2;i++)a[1][i+1]=a[2][i]=1;
if(k%2==1)a[1][1]=1;
}
}
else{
if(k==1)a[1][1]=1;
else if(k==2)a[1][1]=a[n][m]=1;
else if(k==3)a[1][1]=a[n][m]=a[1][m]=1;
else if(k==4)a[1][1]=a[n][m]=a[1][m]=a[n][1]=1;
else{
k-=5;
a[1][2]=a[2][1]=a[2][2]=a[2][3]=a[3][2]=1;
int cur=3;
while(k>3){
if(cur+1>n)break;
a[cur][cur]=a[cur][cur+1]=a[cur+1][cur]=1;
k-=3;
cur++;
}
if(k==1){
k-=1;
a[1][1]=1;
}
if(k>=2&&cur==n){
a[cur][cur]=1;
k--;
if(cur+1<=m)a[cur][cur+1]=1,k--;
}
for(int y0=3;y0<=m&&k>1;y0+=2){
int curx=1,cury=y0;
while (curx<=n&&cury<=m){
a[curx][cury]=1;
k--;
if(cury+1<=m){
a[curx][cury+1]=1,k--;
}
curx++;cury++;
}
}
// cerr<<k<<"\n";
for(int x0=3;x0<=n&&k>1;x0+=2){
int curx=x0,cury=1;
while (curx<=n&&cury<=m){
a[curx][cury]=1;
k--;
if(curx+1<=n){
a[curx+1][cury]=1,k--;
}
curx++;cury++;
}
}
// cerr<<k<<"\n";
if(k)a[1][1]=1;
}
}
if(f){
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++)cout<<a[j][i];
cout<<"\n";
}
}
else{
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)cout<<a[i][j];
cout<<"\n";
}
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n=1;
cin>>n;
while(n--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
input:
2 2 2 2 2 3 0
output:
10 01 000 000
result:
ok Output is valid. OK.
Test #2:
score: -100
Wrong Answer
time: 120ms
memory: 3644kb
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 10 01 11 10 11 11 000 000 100 000 100 001 110 100 011 110 111 110 111 111 00 00 00 10 00 00 10 00 01 11 10 00 01 11 10 11 11 10 11 11 11 000 000 000 100 000 000 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 111 111 011 111 111 111 0000 0000 1000 0000 1000 0001 1...
result:
wrong answer The number of black cell is not K