#include #include typedef unsigned short us; typedef long long int cf; us const p[] = {0xffff, 0x039f, 0xf2f2, 0xf9c8, 0xf900, 0xb0f0}; // 16+8+10+9+6+7 = 56 cf const o = 1; char rn[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; // Next four lines are only for debugging. typedef unsigned long uint32; int gcount(uint32 x) {int c=0; while(x){++c; x &= x-1;} return c;} int bc(cf x){return gcount(x) + gcount(x>>32);} cf twist(cf x){cf s = 0; {int i=4; while(i--) {int j=4; while(j--) {int k=4; while(k--) if(x&(o<<(i+4*j+16*k))) s |= o<<(j+4*k+16*i);}}} return s;} us turn(us px){ return ((px &0xf)<< 4) //1302 rotate piece 90 about long axis | (((px>> 4) )<<12) | ((px>> 8)&0xf) | (((px>>12)&0xf)<< 8);} us tb(us px){ return ((us)rn[ px &0xf]<< 8) //2301 rotate piece 180 about short axis | ((us)rn[(px>> 4)&0xf]<<12) | (us)rn[(px>> 8)&0xf] | ((us)rn[(px>>12) ]<< 4);} cf place(us x){ return ((cf)(x &0xf) << 4) | ((cf)((x>> 4)&0xf) << 8) | ((cf)((x>> 8)&0xf) << 20) | ((cf)((x>>12) ) << 24);} cf pz[6][6][8]; char L[] = {0,1,2,3,4,5}; // last 5 totally permuted by perm char oa[6]; int cnt=0; void x(){cf arena = pz[0][0][0]; void add(char piece){++cnt; if(piece>5) {int j; for(j=0; j