1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| #include<bits/stdc++.h> #define inf 0x3f3f3f3f3f3f3f3fll #define debug(x) cerr<<#x<<"="<<x<<endl using namespace std; using ll=long long; using ld=long double; using pli=pair<ll,int>; using pi=pair<int,int>; template<typename A> using vc=vector<A>; template<typename A,const int N> using aya=array<A,N>; using _=__int128; inline int read() { int s=0,w=1;char ch; while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1; while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } inline ll lread() { ll s=0,w=1;char ch; while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1; while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } const int L=22; struct wtf { ll A,B,C; wtf(ll A=0,ll B=0,ll C=0):A(A),B(B),C(C){} wtf operator + (wtf x){ return wtf(A+x.A,B+x.B,C+x.C);} }; wtf x,y; pi b[300005]; ll a[300005]; int n,c; void exgcd(_ a,_ b,_ &x,_ &y) { if(!b){ x=1,y=0;return ;} _ xp,yp;exgcd(b,a%b,xp,yp); x=yp,y=xp-a/b*yp; } int main() { x=wtf(1,0,0),y=wtf(0,1,0); for(int i=1;i<=L;i++) { wtf mx=x,my=y; x=mx+mx+my;x.C++;y=mx+my; }
_ vA=x.A+y.A,vB=x.B+y.B,X,Y; exgcd(vA,vB,X,Y);
n=read();assert(n%2==0); for(int i=1;i<=n;i++) a[i]=lread(); sort(a+1,a+n+1);
for(int i=1;i<=n;i+=2) { assert(a[i+1]==a[i]+1); ll w=a[i]-1-x.C-y.C;
_ x=X*w,y=Y*w,v=0; if(x<0) v=-((-x+vB-1)/vB); if(y<0) v=(-y+vA-1)/vA; x-=vB*v,y+=vA*v; b[++c]=pi(x,y); }
sort(b+1,b+c+1); string s,t;int sx=0,sy=0,tx=0,ty=0; for(int l=1,r;l<=c;l=r) { r=l+1; while(r<=c&&b[r].first==b[l].first) r++; while(sy<b[l].second) sy++,s+='1'; while(sx<b[l].first) sx++,s+='0';
sx++,s+='0';
while(ty<b[l].second) ty++,t+='1'; while(tx<b[l].first) tx++,t+='0';
while(ty<=b[r-1].second) ty++,t+='1'; tx++,t+='0'; } while(sy<ty) sy++,s+='1'; cout<<s<<endl<<t<<endl; return 0; }
|