QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#599693 | #3223. Cellular Automaton | dongyc666 | WA | 0ms | 4120kb | C++14 | 1.5kb | 2024-09-29 09:09:06 | 2024-09-29 09:09:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int NR=3000;
int n,dis[NR],vis[NR],st[NR*15],L,R;
char str[NR],ans[NR];
#define pii pair<int,int>
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
vector<pii>g[NR];
bool SPFA(){
memset(dis,999999,sizeof(dis));
memset(vis,0,sizeof(vis));
L=R=1;st[1]=0;dis[0]=0;
while(L<=R){
int x=st[L];L++;
if(vis[x]>4*n)return 0;
vis[x]++;
// printf("x:%d %d\n",x,dis[x]);
for(auto lcy:g[x])
if(dis[lcy.fi]>dis[x]+lcy.se){
dis[lcy.fi]=dis[x]+lcy.se;
st[++R]=lcy.fi;
}
}
return 1;
}
bool check(int k){
for(int i=0;i<(1<<(2*n));i++)g[i].clear();
// printf("check:%d %s\n",k,ans);
for(int s=0;s<(1<<(2*n+1));s++){
int x=s>>1,y=s&((1<<(2*n))-1);
if(s<=k){
int val=(ans[s]-'0')-(s&1);
g[x].pb(mkp(y,val));g[y].pb(mkp(x,-val));
}
else{
if(s&1)g[x].pb(mkp(y,0)),g[y].pb(mkp(x,1));
else g[x].pb(mkp(y,1)),g[y].pb(mkp(x,0));
}
}
if(SPFA())return 1;
return 0;
}
bool Check(int x){
ans[x]='0';
return check(x);
}
int main(){
cin>>n;
scanf("%s",str);
if(!check(-1)){
puts("no");
return 0;
}
bool ok=0;
for(int i=0;i<(1<<(2*n+1));i++){
if(ok){
if(Check(i))ans[i]='0';
else ans[i]='1';
}
else{
if(str[i]=='1'){
ans[i]='1';
if(!check(i)){
puts("no");
return 0;
}
}
else{
if(Check(i))ans[i]='0';
else ans[i]='1',ok=1;
}
}
}
printf("%s\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
1 11111111
output:
no
result:
ok single line: 'no'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
1 11111101
output:
no
result:
ok single line: 'no'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
1 11001011
output:
no
result:
ok single line: 'no'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 10111110
output:
no
result:
ok single line: 'no'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
1 10000010
output:
no
result:
ok single line: 'no'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1 00100011
output:
00110011
result:
ok single line: '00110011'
Test #7:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
1 01000001
output:
01000111
result:
ok single line: '01000111'
Test #8:
score: 0
Accepted
time: 0ms
memory: 4120kb
input:
1 00000100
output:
00001111
result:
ok single line: '00001111'
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3756kb
input:
1 01001000
output:
no
result:
wrong answer 1st lines differ - expected: '01010101', found: 'no'