QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587992 | #9114. Black or White 2 | Mu_Silk | AC ✓ | 146ms | 12140kb | C++20 | 2.4kb | 2024-09-24 23:20:07 | 2024-09-24 23:20:08 |
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&&k>1){
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&&k>1){
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: 0ms
memory: 3584kb
input:
2 2 2 2 2 3 0
output:
10 01 000 000
result:
ok Output is valid. OK.
Test #2:
score: 0
Accepted
time: 120ms
memory: 3636kb
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:
ok Output is valid. OK.
Test #3:
score: 0
Accepted
time: 104ms
memory: 9292kb
input:
162 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #4:
score: 0
Accepted
time: 99ms
memory: 7556kb
input:
163 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #5:
score: 0
Accepted
time: 93ms
memory: 7360kb
input:
165 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #6:
score: 0
Accepted
time: 100ms
memory: 4144kb
input:
1020 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #7:
score: 0
Accepted
time: 104ms
memory: 4120kb
input:
1012 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #8:
score: 0
Accepted
time: 100ms
memory: 3860kb
input:
1033 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #9:
score: 0
Accepted
time: 146ms
memory: 3832kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #10:
score: 0
Accepted
time: 73ms
memory: 3604kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #11:
score: 0
Accepted
time: 77ms
memory: 3832kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 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 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
10 01 100 001 110 100 011 110 10 00 01 11 10 00 01 11 10 100 000 001 101 000 001 101 000 101 010 111 010 110 111 010 110 111 011 1000 0001 1100 1000 0110 1100 1110 1100 0111 1110 1000 0000 0001 1001 0000 0001 1001 0000 1001 0100 1110 0100 1100 1110 0100 0100 1110 0111 1100 1110 0111 0111 1110 0111 1...
result:
ok Output is valid. OK.
Test #12:
score: 0
Accepted
time: 98ms
memory: 12140kb
input:
3 1500 1500 2250000 1322 1322 1747684 1158 2 2316
output:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok Output is valid. OK.
Test #13:
score: 0
Accepted
time: 100ms
memory: 11996kb
input:
3 1500 1500 1125000 1322 1322 873842 1158 2 1158
output:
011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok Output is valid. OK.
Extra Test:
score: 0
Extra Test Passed