QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22981 | #2888. 棋盘 | WhybullYMe# | AC ✓ | 4ms | 4196kb | C++20 | 1.6kb | 2022-03-11 13:56:45 | 2022-04-30 02:12:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=310;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
int a[maxn],ans[maxn][maxn],m,n;
int main(){
scanf("%d%d",&n,&m);
for(ri i=1;i<=m;++i)scanf("%d",a+i);
if(n&1){
if(*max_element(a+1,a+m+1)>(n+1>>1))return puts("No"),0;
vector<int>pos;
a[0]=a[m+1]=(n+1)>>1;
for(ri i=0;i<=m+1;++i)
if(a[i]==(n+1>>1)){
if(i-1>0&&i<=m&&a[i-1]==(n+1>>1))return puts("No"),0;
for(ri j=1;j<=n;j+=2)ans[j][i]=1;
pos.push_back(i);
}
for(ri i=0;i+1<pos.size();++i){
if((pos[i]&1)!=(pos[i+1]&1))
for(ri j=pos[i]+1;j<pos[i+1];++j){
for(ri k=n-(((j-pos[i])&1)^1);k>0&&a[j];k-=2){
if(ans[k][j-1]||ans[k][j+1])break;
ans[k][j]=1;
--a[j];
}
for(ri k=((j-pos[i])&1)+1;a[j];k+=2){
if(ans[k][j-1]||ans[k][j+1])return puts("No"),0;
ans[k][j]=1;
--a[j];
}
}
else
for(ri j=pos[i]+1;j<pos[i+1];++j)
for(ri k=1;a[j];++k){
if(k>n)return puts("No"),0;
if(!ans[k][j-1]&&!ans[k-1][j]){
ans[k][j]=1;
--a[j];
}
}
}
}
else{
if(*max_element(a+1,a+m+1)>(n>>1))return puts("No"),0;
for(ri i=1;i<=m;++i)
for(ri j=1;a[i];++j)
if(!ans[j][i-1]&&!ans[j-1][i]){
ans[j][i]=1;
--a[i];
}
}
puts("Yes");
for(ri i=1;i<=n;++i,printf("\n"))
for(ri j=1;j<=m;++j)
putchar(ans[i][j]|48);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3920kb
input:
3 4 2 1 2 1
output:
Yes 1010 0101 1010
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 3ms
memory: 4180kb
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: 3820kb
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: 0ms
memory: 4028kb
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: 3776kb
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: 3960kb
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: 0ms
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: 3728kb
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: 3ms
memory: 3764kb
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 10101010101010101010101010101010100000000101010101010101010101000000000010101010101010101010101010101010101010000000000101010101010101010101000010101010101010101010101000000000000000010101010101010101010101010101010000000000001010101001010101010101010101000000101010101010101010100100101010010010...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 4ms
memory: 4048kb
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: 3912kb
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: 4048kb
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 101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 0101...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 3ms
memory: 3964kb
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: 0ms
memory: 4196kb
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 10101010101010010101010010010101010101010101010101010101010101010101010101001010101010101010101010101010101010010101010101010101010101010010101010010101010100101010010101010101000010101010101010101010101010101010101010101010101010101010100101010101010101010101010101010100101010101010100100100101...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 0ms
memory: 3616kb
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: 3712kb
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 101010100101001010101010101010010101010101010101010101010101010101001010101010101010100100101010101010101010100101010101010101010010101010101010101010101010101010101010101010010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101001 0101...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 2ms
memory: 3996kb
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: 3ms
memory: 4028kb
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: 4ms
memory: 4020kb
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: 3ms
memory: 3980kb
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.