QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#23141 | #2888. 棋盘 | geiwmhdcds | AC ✓ | 9ms | 4216kb | C++20 | 1.9kb | 2022-03-12 08:05:39 | 2022-04-30 02:25:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[100005];
int mat[305][305];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)scanf("%d",&a[i]);
for(int i=1;i<=m;i++)if(a[i]>(n+1)/2)return puts("No"),0;
for(int i=1;i<m;i++)if(a[i]+a[i+1]>n)return puts("No"),0;
if(n%2==0){
for(int i=1;i<=m;i++)
for(int j=(i&1)+1,now=1;now<=a[i];now++,j+=2)mat[j][i]=1;
puts("Yes");
for(int i=1;i<=n;i++,puts(""))for(int j=1;j<=m;j++)printf("%d",mat[i][j]);
return 0;
}
int lst=0;
for(int i=1;i<=m;i++)
if(a[i]==(n+1)/2){
if(lst){
if(i-lst&1){
for(int j=1;j<=n;j+=2){
mat[j][i]=1;
mat[j][lst]=1;
}
int now=1,flag=0;
for(int j=lst+1;j<i;j++){
if(!flag)for(int k=now;k<=n&&a[j];k+=2)if(!mat[k][j-1])mat[k][j]=1,a[j]--;
now=3-now;
if(a[j]==0)flag=1,now=3-now;
for(int k=now;k<=n&&a[j];k+=2)if(!mat[k][j-1]&&!mat[k+1][j]&&!mat[k-1][j])mat[k][j]=1,a[j]--;
// for(int i=1;i<=n;i++,puts(""))for(int j=1;j<=m;j++)printf("%d",mat[i][j]);puts("");
}
for(int j=1;j<=n;j+=2)if(mat[j][i-1])return puts("No"),0;
}else{
for(int j=1;j<=n;j+=2)mat[j][i]=mat[j][lst]=1;
int now=2;
for(int j=lst+1;j<i;j++,now=3-now)
for(int k=now;k<=n&&a[j];k+=2)mat[k][j]=1,a[j]--;
}
}else{
for(int j=1;j<=n;j+=2)mat[j][i]=1;
int now=2;
for(int j=i-1;j>=1;j--,now=3-now)
for(int k=now;k<=now+2*a[j]-2;k+=2)mat[k][j]=1;
}
lst=i;
}
int now=1,flag=0;
for(int j=lst+1;j<=m;j++){
if(!flag)for(int k=now;k<=n&&a[j];k+=2)if(!mat[k][j-1])mat[k][j]=1,a[j]--;
now=3-now;
if(a[j]==0)flag=1,now=3-now;
for(int k=now;k<=n&&a[j];k+=2)if(!mat[k][j-1]&&!mat[k+1][j]&&!mat[k-1][j])mat[k][j]=1,a[j]--;
// for(int i=1;i<=n;i++,puts(""))for(int j=1;j<=m;j++)printf("%d",mat[i][j]);puts("");
}
puts("Yes");
for(int i=1;i<=n;i++,puts(""))for(int j=1;j<=m;j++)printf("%d",mat[i][j]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3724kb
input:
3 4 2 1 2 1
output:
Yes 1010 0101 1010
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 2ms
memory: 4160kb
input:
299 50 150 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 150 123 26 150 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 150
output:
Yes 10101010101010101010010101010101010101010101010101 01010101010101010101001010101010101010101010101010 10101010101010101010010101010101010101010101010101 01010101010101010101001010101010101010101010101010 10101010101010101010010101010101010101010101010101 01010101010101010101001010101010101010101...
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 300 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 0 ...
output:
Yes 00100010101000100001000100101010000000100001010000100100010010101000101010100010101000000000010010101010100010101001010010010010100001000100100101010001010100010000101010001010100101010010100100010100100100101010010100010010100010101010101010010010010010101010010010010010010001010101010101001010...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 4ms
memory: 4060kb
input:
239 300 119 120 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 ...
output:
Yes 01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100101010101010101010101010101010101010101010101010101010...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 3ms
memory: 3736kb
input:
31 300 16 15 13 15 15 13 15 13 14 15 11 16 15 15 15 15 15 15 13 12 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 15 15 12 12 12 11 16 10 15 14 14 15 10 15 15 16 15 12 15 15 15 14 15 15 15 15 15 15 15 14 15 15 15 15 15 15 15 15 16 15 14 13 15 11 12 14 14 16 15 15 14 15 15 15 13 15 15 15 15 15 15 14 14...
output:
Yes 10101010100101010101010101010101001010100101010100101010101010101010101001010101001010101010101010101010010101010101010101010100101010101010101010101010101001010101010101010101010010101010101010101010101010101001010101010101010010101010101010101010101010100101010100101010101010101010101001001001...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 3ms
memory: 4016kb
input:
241 300 0 121 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 12...
output:
No
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 3ms
memory: 3648kb
input:
19 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
No
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 3ms
memory: 3832kb
input:
9 300 5 4 4 4 4 4 3 4 4 5 4 0 5 3 4 4 2 5 2 2 5 2 3 4 4 5 4 4 1 4 5 3 4 3 3 5 4 0 5 3 4 4 4 4 4 4 4 5 4 4 4 4 4 4 4 4 4 4 5 4 4 4 4 4 2 5 2 4 4 4 4 4 5 4 4 4 4 4 4 4 3 5 4 4 4 2 4 4 5 4 4 1 4 5 0 4 5 4 4 4 4 4 4 4 3 5 4 0 5 3 4 2 4 5 4 1 4 4 5 4 4 3 3 4 4 5 4 2 4 3 5 4 3 4 4 4 4 4 4 5 2 2 5 0 4 5 4 ...
output:
Yes 10101010010010100100101001010010100100101010100101010101001010100101010010101010010101001010010010101010010010100101001010100101001010101001001001010100101010100100101010010101001001010101001010010010100101010100100101010010101001010101001010100101001010010101010100101010101001010100100101001001...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 4ms
memory: 3844kb
input:
49 300 25 24 24 24 24 24 24 24 24 24 24 24 21 23 24 24 24 24 24 24 24 24 24 23 24 24 24 24 24 24 24 22 24 24 23 24 24 24 24 24 24 25 24 24 24 24 22 24 24 22 24 24 24 24 24 24 22 24 23 24 24 24 24 15 24 24 24 24 24 24 24 22 25 24 24 23 24 24 24 21 24 24 24 24 24 24 24 23 24 24 24 24 24 24 24 24 24 24...
output:
Yes 10101010101010101010101010101010100101010101010101010101010101001010101010101010101010101010101010101010101010010101010101010101010101010101001010101010101010101010101001010101010101010101010101010101010101010101010010101010101010101001010101010101010101001010101010101010101010100100101010010010...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 7ms
memory: 3964kb
input:
255 300 128 127 125 127 126 126 127 127 115 126 127 124 125 114 126 127 125 127 127 116 126 126 124 127 118 126 127 127 123 122 127 125 126 122 125 125 127 127 127 126 125 127 126 125 127 127 127 127 127 127 125 124 126 124 126 128 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 ...
output:
Yes 10101010101010101010101010101010101010101010101010101001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101001001...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 3ms
memory: 3964kb
input:
241 300 121 118 110 113 21 121 120 120 118 120 113 120 118 115 113 120 112 120 120 117 120 118 115 113 120 115 113 118 117 120 108 119 120 120 119 120 120 120 120 116 117 120 113 118 115 120 121 120 104 109 116 120 120 115 118 115 102 113 116 120 119 119 120 108 117 118 120 120 102 121 118 119 120 1...
output:
No
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 4ms
memory: 4216kb
input:
298 291 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 ...
output:
Yes 010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 1010...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 5ms
memory: 4212kb
input:
299 100 150 146 149 148 149 139 127 149 142 146 149 146 149 143 149 149 149 149 147 149 147 149 149 146 137 148 148 147 142 149 149 146 147 149 149 147 148 135 142 142 146 149 147 147 149 150 145 144 141 135 149 141 147 131 145 148 148 149 143 149 137 148 147 146 144 140 115 148 149 149 150 149 149 ...
output:
Yes 1010101010101010101010101010101010101010101001010101010101010101010100101010101010100101010100100000 0101010101010101010101010101010101010101010010101010101010101010101001010101010101010010101010000000 1010101010101010101010101010101010101010101001010101010101010101010010101010101010100101010100...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 9ms
memory: 4080kb
input:
300 299 150 150 150 150 144 150 150 150 111 150 113 150 150 150 0 150 147 150 150 139 125 150 117 0 150 0 0 150 127 136 150 150 0 111 150 150 150 129 150 150 150 150 135 150 150 150 150 150 113 150 139 121 116 148 139 130 150 122 150 150 150 150 150 129 150 129 150 150 142 126 150 150 150 132 150 0 ...
output:
Yes 01010101010101010101010000010101010101010101010101010101010101010101010101000101010101010101010100010101010101010101010101010101010101010001000101010101010100010101010101010101000001010101000101010100010101010101010101010001010101010101010101010101010101010101010101010100010101010101010100010101...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 3ms
memory: 3532kb
input:
100 290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
No
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 3ms
memory: 3804kb
input:
2 291 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
Yes 010101010101000101010101010001010101010101010101010101010101010101000101010101010101010100000101010101010101010101010101010101010001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000 1010...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 7ms
memory: 4072kb
input:
231 299 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 115 116 ...
output:
Yes 10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
result:
ok Correct.
Test #18:
score: 0
Accepted
time: 0ms
memory: 4068kb
input:
233 219 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 117 116 ...
output:
Yes 010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 1010101010101010101010101010101010101010101010101010101010101010101010101010...
result:
ok Correct.
Test #19:
score: 0
Accepted
time: 6ms
memory: 4136kb
input:
233 219 117 55 61 117 81 35 117 97 19 117 103 13 117 76 40 117 34 82 117 112 4 117 67 49 117 106 10 117 110 6 117 25 91 117 115 1 117 82 34 117 45 71 117 46 70 117 55 61 117 101 15 117 108 8 117 101 15 117 6 110 117 53 63 117 114 2 117 62 54 117 24 92 117 63 53 117 83 33 117 43 73 117 67 49 117 73 4...
output:
Yes 100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100 0100100100100100100100100100100100100100100100100100100100100100100100100100...
result:
ok Correct.
Test #20:
score: 0
Accepted
time: 1ms
memory: 4084kb
input:
299 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
No
result:
ok Correct.