UVa 253

UVa 253

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <string>
 4 #include <cstring>
 5 #include <cmath>
 6 #include <sstream>
 7 #include <algorithm>
 8 #include <set>
 9 #include <map>
10 #include <vector>
11 #include <queue>
12 #include <iomanip>
13 #include <stack>
14 
15 using namespace std;
16 
17 typedef long long LL;
18 const int INF = 0x3f3f3f3f;
19 const int MAXN = 100005;
20 const int MOD = 1e9 + 7;
21 
22 #define MemI(x) memset(x, -1, sizeof(x))
23 #define Mem0(x) memset(x, 0, sizeof(x))
24 #define MemM(x) memset(x, 0x3f, sizeof(x))
25 
26 //把骰子的每一个面都放在第一面,有 6 种可能,然后第一面不变,中间四个面旋转
27 int dis[7][7] = {{0, 1, 2, 3, 4, 5}, {1, 5, 2, 3, 0, 4}, {2, 0, 1, 4, 5, 3}, {3, 1, 0, 5, 4, 2}, {4, 0, 2, 3, 5, 1}, {5, 4, 2, 3, 1, 0}};
28 int main()
29 {
30     string s;
31     while(cin >> s)
32     {
33         string a, b;
34         int i, j;
35         for(i = 0;i < 6;++i)
36             a += s[i];
37         for(i = 6;i < 12;++i)
38             b += s[i];
39         a[6] = b[6] = 0;//分开两种面的情况
40         int flag = 0;
41         for(i = 0;i < 6 && !flag;++i)
42         {
43             string t;
44             for(j = 0;j < 6;++j)
45                 t += a[dis[i][j]];
46             t[6] = 0;
47             if(t == b)
48                 flag = 1;
49             //旋转中间四个面,可以发现 1 面是从 3 面转来的 (编号从 0 开始),以此类推
50             for(j = 0;j < 3 && !flag;++j)
51             {
52                 char p = t[1];
53                 t[1] = t[3];
54                 t[3] = t[4];
55                 t[4] = t[2];
56                 t[2] = p;
57                 if(t == b)
58                     flag = 1;
59             }
60         }
61         if(flag)
62             cout << "TRUE" << endl;
63         else
64             cout << "FALSE" << endl;
65     }
66     return 0;
67 }
现在所有的不幸都是以前不努力造成的。。。
原文地址:https://www.cnblogs.com/shuizhidao/p/9370390.html