QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#42577 | #3223. Cellular Automaton | _Veritas | WA | 1ms | 1832kb | C++ | 1022b | 2022-08-02 18:18:13 | 2022-08-02 18:18:16 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,fst,k,l,sc,cnt=0;
bool v[130],s[130],st[130],b=0;
//char str[8][4]={"000","001","010","011","100","101","110","111"};
void solveu(int x,bool lim)
{
if(b) return;
st[sc++]=(x&1);
v[x]=1;
if(sc==(1<<n))
{
/*for(int i=0;i<sc-n+1;++i) printf("%d",(st[i]&1));*/
for(int i=n-1;i>0;--i) printf("%d",((m>>i)&1));
for(int i=0;i<sc-n+1;++i) printf("%d",st[i]);
putchar('\n');
b=1;
}
else
{
if(((!s[sc+n-1])||(!lim))&&(!v[(x<<1)&((1<<n)-1)])) solveu((x<<1)&((1<<n)-1),lim);
if(!v[((x<<1)|1)&((1<<n)-1)]) solveu(((x<<1)|1)&((1<<n)-1),lim&&s[sc+n-1]);
}
v[x]=0;
--sc;
}
int main()
{
scanf("%d",&n);
n=n*2+1;
char c=getchar();
while(c>'1'||c<'0') c=getchar();
for(int i=0;!(i>>n);++i)
{
s[i]=(c^'0');
c=getchar();
}
fst=0;
for(int i=0;i<n;++i) fst=((fst<<1)|s[i]);
m=fst;
solveu(m,1);
for(m=fst+1;!((m>>n)||b);++m) solveu(m,0);
if(!b) printf("no\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 1832kb
input:
1 11111111
output:
no
result:
ok single line: 'no'
Test #2:
score: 0
Accepted
time: 1ms
memory: 1800kb
input:
1 11111101
output:
no
result:
ok single line: 'no'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 1748kb
input:
1 11001011
output:
11010001
result:
wrong answer 1st lines differ - expected: 'no', found: '11010001'