#include #include using namespace std; struct dice{ int side[6]; //current side arrangement int sideb[6]; //original arrangement of the sides void direct(int d,int r){ //direct the dice to desired arrangement //d <-[0..5] -- where to put side 0 //r <-[0..3] -- rotation around side 0 int v[]={ 0,1,2,3,4,5, 4,0,2,3,5,1, 5,4,2,3,1,0, 1,5,2,3,0,4, 2,1,5,0,4,3, 3,1,0,5,4,2 }; int u[]={ 0,1,2,3,4,5, 0,3,1,4,2,5, 0,4,3,2,1,5, 0,2,4,1,3,5 }; for(int i = 0; i<6;i++) side[i]=sideb[v[6*d+u[6*r+i]]]; }; }tbl[6]; bool consistent(int depth){ //check for consistency from dice no. 0..depth for(int s=1;s<=4;s++){ int used[6]={0}; for(int i=0;i<=depth;i++){ int cur = tbl[i].side[s]-1; if(used[cur]) return false; used[cur]=1; } } return true; } int solve(int depth){ int sum=0; if(depth>=6)return 1; for(int d=0;d<6;d++){ int rlimit =4; for(int r = 0; r< rlimit; r++){ tbl[depth].direct(d,r); if(consistent(depth)){ sum+=solve(depth+1); } } } return sum; } int main(){ int n; ifstream cin("dice.txt"); cin >> n; for(int cases=0;cases> tbl[i].sideb[j]; } int ans = solve(0)/8; cout <