Test instructions: Give the state of a second-order Rubik's Cube, and ask whether it can be restored;
Reference: http://blog.csdn.net/squee_spoon/article/details/46990969 (Zhengda University Cuber)
Idea: A second-order Rubik's Cube adjacent corner block Exchange situation such as;
Each square of the final state is assigned a value, and the weight value does not change after rotation;
Considering the dry medium and yellow as the opposite, the weight of the value of 0;
Assign 1 clockwise, otherwise-1;
If the weights and the weight of the yellow block are divisible by three, it can be restored;
#include <cstdio>#include<cstring>#include<algorithm>using namespacestd;intT,n,m,ans;Charstr[ -];intmark[]={1,-1,-1,1,-1,1,0,0,-1,1,1,-1,0,0,1,-1,1,-1,-1,1,0,0,0,0};intMain () {intI,j,k,cas; scanf ("%d",&t); for(cas=1; cas<=t;cas++) {ans=0; for(i=0;i< -; i++) {scanf ("%s", str); if(str[0]=='W'|| str[0]=='y') {ans+=Mark[i]; }} printf ("Case #%d:", CAs); if(ans%3==0) printf ("yes\n"); Elseprintf"no\n"); } return 0;}
HDU Pocket Cube (concluding question)