QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398635#5434. Binary SubstringsdengziyueWA 10ms13764kbC++141.3kb2024-04-25 15:59:572024-04-25 16:00:04

Judging History

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

  • [2024-04-25 16:00:04]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:13764kb
  • [2024-04-25 15:59:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define max_n 900000
int n;
int m;
int lim;
int a[max_n+2],ai=0;
bool vis[max_n+2];
int to[max_n+2];
void dfs(int u){
	a[++ai]=u; vis[u]=true;
	if(u==20){printf("pay attention\n");}
	for(int i=1,v;i>=0;--i){
		v=(u<<1|i)&((1<<m)-1);
		if(!vis[v])dfs(v);
	}
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("QOJ5434_1.in","r",stdin);
	freopen("QOJ5434_1.out","w",stdout);
	#endif
	scanf("%d",&n);
	if(n==1){printf("0\n"); return 0;}
	if(n==2){printf("01\n"); return 0;}
	if(n==3){printf("010\n"); return 0;}
	for(int i=1;i<=20;++i){
		if((1<<i)<=n-i+1)m=i;
	}
	dfs(0);
	if(n==(1<<m)+m-1){
		for(int i=1;i<m;++i)printf("%d",0);
		for(int i=1;i<=ai;++i)printf("%d",a[i]&1);
		return 0;
	}
	for(int i=1;i<=ai;++i)a[i]=a[i]<<1|(a[i+1]&1);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=ai;++i)vis[a[i]]=true;
	memset(to,-1,sizeof(to));
	for(int i=1;i<=ai;++i)to[a[i]]=a[i%ai+1];
	for(int x=0;x<(1<<(m+1));++x){
		if(to[x]==-1)to[x]=to[x^(1<<m)]^1;
	}
	for(int x=1;x<(1<<(m+1));++x){
		if(vis[x])continue;
		for(int u=x;!vis[u];u=to[u]){vis[u]=true; ++ai;}
		swap(to[x],to[x^(1<<m)]);
		if(m+ai>=n){
			for(int i=m;i>=1;--i)printf("%d",(to[x]>>i)&1);
			int u=to[x];
			for(int i=m+1;i<=n;++i,u=to[u])printf("%d",u&1);
			return 0;
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

input:

2

output:

01

result:

ok meet maximum 3

Test #2:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

5

output:

00110

result:

ok meet maximum 12

Test #3:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1

output:

0

result:

ok meet maximum 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

3

output:

010

result:

ok meet maximum 5

Test #5:

score: 0
Accepted
time: 2ms
memory: 8192kb

input:

4

output:

1011

result:

ok meet maximum 8

Test #6:

score: 0
Accepted
time: 0ms
memory: 8248kb

input:

6

output:

100110

result:

ok meet maximum 16

Test #7:

score: 0
Accepted
time: 0ms
memory: 8316kb

input:

7

output:

1001101

result:

ok meet maximum 21

Test #8:

score: 0
Accepted
time: 2ms
memory: 8248kb

input:

8

output:

10011010

result:

ok meet maximum 27

Test #9:

score: 0
Accepted
time: 0ms
memory: 8204kb

input:

9

output:

110100111

result:

ok meet maximum 34

Test #10:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

10

output:

0001110100

result:

ok meet maximum 42

Test #11:

score: 0
Accepted
time: 2ms
memory: 8280kb

input:

11

output:

01000111010

result:

ok meet maximum 50

Test #12:

score: 0
Accepted
time: 1ms
memory: 8268kb

input:

12

output:

010001110101

result:

ok meet maximum 59

Test #13:

score: -100
Wrong Answer
time: 10ms
memory: 13764kb

input:

200000

output:

pay attention
0000000001110011011100110011100110111001010111001101110010001110011011100011011100110111000100111001101110000101110011011100000011100110110111000111001101101101101110011011011010011100110110110010111001101101100001110011011010110011100110110101010111001101101010001110011011010011011100...

result:

wrong answer Token parameter [name=s] equals to "pay", doesn't correspond to pattern "[01]{200000}"