QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397913#5434. Binary SubstringsqwqUwU_WA 1ms4256kbC++172.0kb2024-04-24 19:41:182024-04-24 19:41:18

Judging History

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

  • [2024-04-24 19:41:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4256kb
  • [2024-04-24 19:41:18]
  • 提交

answer

// clang-format off
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
mt19937 gen(time(0));
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<int,ll> pil;
inline ll read(){
	ll x=0,f=1,c=getchar();
	while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int mod=998244353;
inline int fp(int x,ll p=mod-2,int m=mod,int res=1){
	for(;p;p>>=1){if(p&1)res=1ll*res*x%m;x=1ll*x*x%m;}
	return res;
}
inline void plust(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
const int N=2e5+3;
// clang-format on
int n,m,a[N],tot,lim;
bool vis[N][2];
inline void check(){
	if(tot>lim)return;
	rep(i,1,n)printf("%d",a[i]);
	exit(0);
}
inline void dfs(int u){
	check();
	if(!vis[u][0]){
		vis[u][0]=1;
		dfs((u<<1|0)&((1<<(m-1))-1));
		a[tot--]=0;
		check();
	}
	if(!vis[u][1]){
		vis[u][1]=1;
		dfs((u<<1|1)&((1<<(m-1))-1));
		a[tot--]=1;
		check();
	}
}
inline void dfs2(int u){
	check();
	if(!vis[u][0]){
		vis[u][0]=1;
		dfs2((u<<1|0)&((1<<m)-1));
		a[tot--]=0;
		check();
	}
	if(!vis[u][1]){
		vis[u][1]=1;
		dfs2((u<<1|1)&((1<<m)-1));
		a[tot--]=1;
		check();
	}
}
int main() {
    //freopen("data.in", "r", stdin);
    // freopen(".in","r",stdin);
    // freopen("myans.out","w",stdout);
	n=read();
	if(n==1){puts("1");return 0;}
	if(n==2){puts("01");return 0;}
	for(;(1<<m)+m-1<=n;++m);--m;
	tot=(1<<m)+m-1;
	dfs(0);//vertex :2^{m-1},edge :2^m
	lim=(1<<m)+m-1;
	cout<<m<<endl;
	//rep(i,1,tot)printf("%d",a[i]);
	memset(vis,0,sizeof vis);
	rep(i,1,(1<<m)-1){
		int u=0;
		rep(j,i,i+m-1)u=u<<1+a[j];
		vis[u][a[i+m]]=1;
	}
	tot=n;
	rep(i,0,(1<<m)-1)dfs2(i);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2

output:

01

result:

ok meet maximum 3

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4256kb

input:

5

output:

2
00110

result:

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