魔方的题,暴力睡过。1930ms,差点久挂了。
#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include #define LL long long #define DB double #define SI(a) scanf("%d",&a) #define SD(a) scanf("%lf",&a) #define SS(a) scanf("%s",a) #define PF printf #define MM(a,b) memset(a,b,sizeof(a)) #define REP(i,a,b) for(int i=a;ib;i--) #define INF 0x3f3f3f3f #define EPS 1e-8 #define bug puts("bug") using namespace std; #define N 25 int tun1[3][4] = { 2,3,1,0, 7,6,12,13, 8,9,15,14 }; int tun2[3][8] = { 4,5,6,7,8,9,23,22, 3,2,5,11,16,17,14,8, 23,21,19,17,13,7,3,1, }; struct nod{ int re[N]; void in() { REP(i,0,24) SI(re[i]); } int cc(int a,int b,int c,int d) { if(re[a]==re[b]&&re[b]==re[c]&&re[c]==re[d]) return 1; return 0; } int get() { int ret =0; if(cc(0,1,2,3)) ret++; if(cc(4,5,11,10)) ret++; if(cc(6,7,12,13)) ret++; if(cc(8,9,14,15)) ret++; if(cc(16,17,18,19)) ret++; if(cc(20,21,22,23)) ret++; return ret; } void oor(int k) { int t; t = re[tun1[k][3]]; REPD(i,3,0) re[tun1[k][i]] = re[tun1[k][i-1]]; re[tun1[k][0]] = t; t = re[tun2[k][7]]; REPD(i,7,0) re[tun2[k][i]] = re[tun2[k][i-1]]; re[tun2[k][0]] = t; t = re[tun2[k][7]]; REPD(i,7,0) re[tun2[k][i]] = re[tun2[k][i-1]]; re[tun2[k][0]] = t; } void l1(int k) { oor(k); } void l2(int k) { oor(k);oor(k); oor(k); } } ini,tmp; int pow(int k) { int ret = 1; while(k--) { ret *= 6; } return ret; } int ans = 0; void solve(int c,int k) { for(int i=0;i