UVA 253 - Cube painting
来源:互联网 发布:python语言介绍 编辑:程序博客网 时间:2024/04/25 15:25
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char A[13];int temp[24][6] = { {1, 2, 3, 4, 5, 6}, {2, 6, 3, 4, 1, 5}, {3, 2, 6, 1, 5, 4}}; //由三个构造出24个void op1(int i){ int j = 3+i; memcpy(temp[j], temp[i], sizeof(temp[0])); swap(temp[j][0], temp[j][5]); swap(temp[j][1], temp[j][4]);}void op2(int i){ int j = 6+i; memcpy(temp[j], temp[i], sizeof(temp[0])); swap(temp[j][1], temp[j][2]); swap(temp[j][3], temp[j][4]); swap(temp[j][1], temp[j][4]);}void op3(int i){ int j = 12+i; memcpy(temp[j], temp[i], sizeof(temp[0])); swap(temp[j][1], temp[j][4]); swap(temp[j][2], temp[j][3]);}int found(){ for(int i=0; i<24; i++) { int j; for(j=0; j<6; j++) { if(A[temp[i][j] - 1] != A[6+j]) { break; } } if(j == 6) return 1; } return 0;}int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif for(int i=0; i<3; i++) { op1(i); } for(int i=0; i<6; i++) { op2(i); } for(int i=0; i<12; i++) { op3(i); } while(scanf("%s", A) ==1) { if(found()) { printf("TRUE\n"); } else { printf("FALSE\n"); } }}