传送门:QAQ
题意:两阶魔方能否一次还原
代码:
#include<stdio.h>
int ax[15][8];
int bn[15][8];
int check() {
int fla=1;
for (int i = 0; i < 6; i++) {
for (int z = 1; z <= 4; z++) {
if (bn[i][z] != bn[i][1]) {
fla = 0;
break;
}
}
}
return fla;
}
int main(void) {
int t;
scanf("%d", &t);
while (t--) {
for (int i = 0; i < 6; i++) {
for (int z = 1; z <= 4; z++) {
scanf("%d", &ax[i][z]);
bn[i][z] = ax[i][z];
}
}
if (check()) {
printf("YES\n");
continue;
}
if (ax[0][1] == ax[0][3] && ax[0][3] == ax[1][2]&& ax[1][2] == ax[1][4] && ax[1][1] == ax[1][3] && ax[1][3] == ax[2][2]&& ax[2][2] == ax[2][4] && ax[2][1] == ax[2][3] && ax[2][3] == ax[3][2]&& ax[3][2] == ax[3][4] && ax[3][1] == ax[3][3] && ax[3][3] == ax[0][2] && ax[0][2] == ax[0][4] && ax[5][1] == ax[5][2] && ax[5][2] == ax[5][3] && ax[5][3] == ax[5][4] && ax[4][1] == ax[4][2] && ax[4][2] == ax[4][3]&& ax[4][3] == ax[4][4]) {
printf("YES\n");
}
else if (ax[0][1] == ax[0][3] && ax[0][3] == ax[3][2]&& ax[3][2] == ax[3][4] && ax[3][1] == ax[3][3] && ax[3][3] == ax[2][2]&& ax[2][2] == ax[2][4] && ax[2][1] == ax[2][3] && ax[2][3] == ax[1][2]&& ax[1][2] == ax[1][4] && ax[1][1] == ax[1][3] && ax[1][3] == ax[0][2]&& ax[0][2] == ax[0][4] && ax[5][1] == ax[5][2] && ax[5][2] == ax[5][3]&& ax[5][3] == ax[5][4] && ax[4][1] == ax[4][2] && ax[4][2] == ax[4][3]&& ax[4][3] == ax[4][4]) {
printf("YES\n");
}
else if (ax[0][2] == ax[0][1] && ax[0][1] == ax[4][4]&& ax[4][4] == ax[4][3] && ax[4][2] == ax[4][1] && ax[4][1] == ax[2][1]&& ax[2][1] == ax[2][2] && ax[2][3] == ax[2][4] && ax[2][4] == ax[5][3] && ax[5][3] == ax[5][4] && ax[5][1] == ax[5][2] && ax[5][2] == ax[0][3]&& ax[0][3] == ax[0][4] && ax[1][1] == ax[1][2] && ax[1][2] == ax[1][3]&& ax[1][3] == ax[1][4] && ax[3][1] == ax[3][2] && ax[3][2] == ax[3][3]&& ax[3][3] == ax[3][4]) {
printf("YES\n");
}
else if (ax[0][2] == ax[0][1] && ax[0][1] == ax[5][4]&& ax[5][4] == ax[5][3] && ax[5][2] == ax[5][1] && ax[5][1] == ax[2][1] && ax[2][1] == ax[2][2] && ax[2][3] == ax[2][4] && ax[2][4] == ax[4][3]&& ax[4][3] == ax[4][4] && ax[4][1] == ax[4][2] && ax[4][2] == ax[0][3]&& ax[0][3] == ax[0][4] && ax[1][1] == ax[1][2] && ax[1][2] == ax[1][3]&& ax[1][3] == ax[1][4] && ax[3][1] == ax[3][2] && ax[3][2] == ax[3][3]&& ax[3][3] == ax[3][4]) {
printf("YES\n");
}
else if (ax[3][2] == ax[3][1] && ax[3][1] == ax[5][1]&& ax[5][1] == ax[5][3] && ax[5][2] == ax[5][4] && ax[5][4] == ax[1][1]&& ax[1][1] == ax[1][2] && ax[1][3] == ax[1][4] && ax[1][4] == ax[4][2]&& ax[4][2] == ax[4][4] && ax[4][1] == ax[4][3] && ax[4][3] == ax[3][3] && ax[3][3] == ax[3][4] && ax[2][1] == ax[2][2] && ax[2][2] == ax[2][3]&& ax[2][3] == ax[2][4] && ax[0][1] == ax[0][2] && ax[0][2] == ax[0][3]&& ax[0][3] == ax[0][4]) {
printf("YES\n");
}
else if (ax[3][4] == ax[3][3] && ax[3][3] == ax[5][2]&& ax[5][2] == ax[5][4] && ax[5][3] == ax[5][1] && ax[5][1] == ax[1][3]&& ax[1][3] == ax[1][4] && ax[1][1] == ax[1][2] && ax[1][2] == ax[4][3]&& ax[4][3] == ax[4][1] && ax[4][4] == ax[4][2] && ax[4][2] == ax[3][1]&& ax[3][1] == ax[3][2] && ax[2][1] == ax[2][2] && ax[2][2] == ax[2][3]&& ax[2][3] == ax[2][4] && ax[0][1] == ax[0][2] && ax[0][2] == ax[0][3]&& ax[0][3] == ax[0][4]) {
printf("YES\n");
}
else printf("NO\n");
}
return 0;
}