QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#23010 | #2888. 棋盘 | hy_zheng_zai_nei_juan# | AC ✓ | 8ms | 7596kb | C++20 | 3.7kb | 2022-03-11 15:18:39 | 2022-04-30 00:39:41 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
#define BUF_SIZE 100000
bool IOerror=0;
inline char nc()
{
static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
if (p1==pend){
p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
if (pend==p1){IOerror=1;return -1;}
}
return *p1++;
}
inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
inline ll read()
{
bool sign=0; char ch=nc();ll x=0;
for (;blank(ch);ch=nc());
if (IOerror)return 0;
if (ch=='-')sign=1,ch=nc();
for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
if (sign)x=-x;
return x;
}
#undef BUF_SIZE
};
using namespace fastIO;
int a[1000010],c[1010][1010],n,m;
vector<int>v;
bool doit(int l,int r)
{
if(l>r)return 0;
if((r-l+1)&1)
{
int f=0;
for(int i=l;i<=r;i++)
{
f^=1;
for(int p=f+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
}
return 1;
}
else
{
int f=1;
int pos=f-1;
for(int p=f+1,j=1;j<=a[l];p+=2,j++)
{
c[p][l]=1;
pos=p;
}
f^=1;
for(int i=l+1;i<=r;i++)
{
f^=1;
int num=1;
for(int p=n-f;num<=a[i];num++,p-=2)
{
// cout<<p<<":"<<c[p][i-1]<<'\n';
if(c[p][i-1])break;
else c[p][i]=1;
}
// cout<<i<<":"<<num<<'\n';
if(num>a[i])continue;
else if(i==r)return 0;
else
{
f^=1;
for(int p=f+1;num<=a[i];num++,p+=2)c[p][i]=1;//cout<<p<<' ';cout<<'\n';
f^=1;
}
/*
if(!g&&a[i]+a[i-1]<=n/2+((i-1-l)&1))
{
for(int p=pos+2,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
g=1;
continue;
}
f^=1;
pos=f-1;
for(int p=f+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
pos=p;
}
*/
}
return 1;
}
}
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=qr,m=qr;
for(int i=1;i<=m;i++)in(a[i]);
if(n%2==0)
{
int f=0;
for(int i=1;i<=m;i++)
{
if(a[i]>n/2)
{
f=1;
break;
}
for(int p=(i&1)+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
}
if(f)puts("No");
else
{
puts("Yes");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)cout<<c[i][j];
cout<<'\n';
}
}
return 0;
}
else
{
int f=0;
for(int i=1;i<=m;i++)
{
if(a[i]>n/2+1)f=1;
if(a[i]==n/2+1)
{
for(int j=1;j<=n;j+=2)c[j][i]=1;
// cout<<i<<'\n';
v.push_back(i);
}
}
if(f)return puts("No"),0;
if(!v.size())
{
for(int i=1;i<=m;i++)
{
for(int p=(i&1)+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
}
}
else
{
int f=0;
for(int i=v[0]-1;i>=1;i--)
{
f^=1;
for(int p=f+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
}
f=0;
// cout<<v.back()<<endl;
for(int i=v.back()+1;i<=m;i++)
{
// cout<<i<<endl;
f^=1;
for(int p=f+1,j=1;j<=a[i];p+=2,j++)
{
c[p][i]=1;
}
}
// cout<<v.size()<<'\n';
for(int i=0;i<v.size()-1;i++)
{
if(!doit(v[i]+1,v[i+1]-1))return puts("No"),0;
}
}
puts("Yes");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)cout<<c[i][j];
cout<<'\n';
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5636kb
input:
3 4 2 1 2 1
output:
Yes 1010 0101 1010
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 4ms
memory: 7024kb
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: 3ms
memory: 5588kb
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: 7ms
memory: 7264kb
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: 2ms
memory: 5852kb
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: 2ms
memory: 7152kb
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: 1ms
memory: 5684kb
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: 5832kb
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: 5940kb
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: 7232kb
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: 1ms
memory: 6968kb
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: 2ms
memory: 7484kb
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: 2ms
memory: 7124kb
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: 8ms
memory: 7596kb
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: 5504kb
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: 5580kb
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: 7176kb
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: 5ms
memory: 6848kb
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: 0ms
memory: 6968kb
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 100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100101 0100100100100100100100100100100100100100100100100100100100100100100100100100...
result:
ok Correct.
Test #20:
score: 0
Accepted
time: 4ms
memory: 6908kb
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.