/* coder: ACboy date: 2010-3-3 result: AC description: UVa 253 - Cube painting */ #include <iostream> using namespace std; // 上下旋转 (绕y轴旋转) void rotate3(char a[]) { char temp = a[0]; a[0] = a[2]; a[2] = a[5]; a[5] = a[3]; a[3] = temp; } // 左右旋转 (绕z轴旋转) void rotate2(char a[]) { char temp = a[4]; a[4] = a[3]; a[3] = a[1]; a[1] = a[2]; a[2] = temp; } // 横向旋转(绕y轴旋转) void rotate1(char a[]) { char temp = a[0]; a[0] = a[4]; a[4] = a[5]; a[5] = a[1]; a[1] = temp; } int main() { int i, j; char a[7], b[7]; char temp[10]; char input[20]; #ifndef ONLINE_JUDGE freopen("253.txt", "r", stdin); #endif while (gets(input)) { int len = strlen(input); int ac = 0; int bc = 0; for (i = 0; i < len; i++) { if (i < 6) { a[ac++] = input[i]; } else { b[bc++] = input[i]; } } a[ac] = '/0'; b[bc] = '/0'; int ok = 0; strcpy(temp, a); for (i = 0; i < 4; i++) { rotate1(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } for (j = 0; j < 4; j++) { rotate2(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } } } strcpy(temp, a); for (i = 0; i < 4; i++) { rotate2(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } for (j = 0; j < 4; j++) { rotate3(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } } } strcpy(temp, a); for (i = 0; i < 4; i++) { rotate1(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } for (j = 0; j < 4; j++) { rotate3(temp); if (strcmp(temp, b) == 0) { ok = 1; break; } } } if (ok) { cout << "TRUE" << endl; } else { cout << "FALSE" << endl; } } return 0; }