QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#42577#3223. Cellular Automaton_VeritasWA 1ms1832kbC++1022b2022-08-02 18:18:132022-08-02 18:18:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-02 18:18:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:1832kb
  • [2022-08-02 18:18:13]
  • 提交

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'