#include <iostream> #include <string> using namespace std;
bool sameC(int arr[2][8]) { bool sam[3][8] = { false }; for (int i = 0; i < 8; i++) { if (arr[0][i] == arr[1][i]) sam[0][i] = true; if (arr[0][i] == arr[1][(i + 2) % 8]) sam[1][i] = true; if (arr[0][i] == arr[1][(i + 6) % 8]) sam[2][i] = true; } bool sam2[3] = { true, true, true }; for (int i = 0; i < 3; i++) for (int j = 0; j < 8; j++) if (!sam[i][j]) sam2[i] = false; if (sam2[0] || sam2[1] || sam2[2]) return true; return false; }
bool solve(int* data) { int c1[2][8] = { {0, 2, 4, 6, 8, 10, 12, 14}, {1, 3, 5, 7, 9, 11, 13, 15} }; int c2[2][8] = { {11, 10, 16, 17, 0, 1, 20, 21}, {9, 8, 18, 19, 2, 3, 22, 23} }; int c3[2][8] = { {17, 19, 4, 5, 22, 20, 15, 14}, {16, 18, 6, 7, 23, 21, 13, 12} }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 8; j++) { c1[i][j] = data[c1[i][j]]; c2[i][j] = data[c2[i][j]]; c3[i][j] = data[c3[i][j]]; } } bool sameColor = false; if (sameC(c1) && sameC(c2) && sameC(c3)) sameColor = true; return sameColor; }
int main() { int N; cin >> N; while (N--) { int data[26]; for (int i = 0; i < 24; i++) cin >> data[i]; bool res = solve(data); if (res) cout << "YES" << endl; else cout << "NO" << endl; }
return 0; }
|