I - Infinite Improbability Drive

时间:2023-03-08 15:19:11
I - Infinite Improbability Drive

I - Infinite Improbability Drive
http://codeforces.com/gym/241750/problem/I
不断构造,先填n-1个0,然后能放1就放1,最后这个序列的长度就是(1<<n)+n-1,也就是每添加1位就要匹配出来一个。

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
int n;
int a[];
bool vis[];
int ans,t,fin; void in(int &x){
int y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(int x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
freopen("infinite.in","r",stdin);
freopen("infinite.out","w",stdout);
in(n);
fin=(<<n)+n-;
a[n]=;
vis[]=;
For(i,n+,fin){
a[i]=;
t=;
ans=;
for(int j=i;j>=i-n+;j--){
ans+=t*a[j];
t<<=;
}
if(vis[ans]){
vis[ans-]=;
a[i]=;
}
else
vis[ans]=;
}
For(i,,fin)
o(a[i]);
return ; }