CodeChef submission 601251 (C) plaintext list. Status: AC, problem SEQUENCE, contest . By karlheinz_jung (karlheinz_jung), 2011-07-18 18:24:48.

#include <stdio.h> #define R(a,b) ((p<<a)+(q<<b)) #define S(a,b,c) if(a){x=b;y=c;} main() { int fall, a, b, n, i, j, x, y, k, p, q, e[1<<17], c[1<<17]; for(i=0; i<=15; e[1<<i]=i++); { { c[i]=i^(i>>1); S((i>0&&((c[i]==a&&c[i-1]==b)||(c[i]==b&&c[i-1]==a))),i-1,i) } i--; S((c[0]==a&&c[i]==b)||(c[0]==b&&c[i]==a),0,i) if(x>=0) for(j=e[c[x]^c[y]]+(k=0); k<n; k++) if(j!=k) { for(x=y=-!(i=0); i<(1<<n); i++) { p=(c[i]>>j)&1; q=(c[i]>>k)&1; c[i]+=-R(j,k)+R(k,j); S((i>0&&((c[i]==a&&c[i-1]==b)||(c[i]==b&&c[i-1]==a))),i-1,i) } i--; S(((c[0]==a&&c[i]==b)||(c[0]==b&&c[i]==a)),0,i) if(x==-1)break; } } return 0; }

## Comments

**Please login at the top to post a comment.**