-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCube_painting.cpp
47 lines (47 loc) · 1.15 KB
/
Cube_painting.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <string.h>
typedef struct {
char p[6];
} Dice;
int cmp(Dice x, Dice y) {
static int i;
for(i = 0; i < 6; i++)
if(x.p[i] != y.p[i])
return x.p[i] - y.p[i];
return 0;
}
Dice MinExp(Dice x) {
Dice y = x;
int i, j, t;
for(i = 0; i < 4; i++) { /*x_rotate*/
for(j = 0; j < 4; j++) { /*y_rotate*/
t = x.p[2], x.p[2] = x.p[0], x.p[0] = x.p[3];
x.p[3] = x.p[5], x.p[5] = t;
if(cmp(y, x) > 0) y = x;
}
for(j = 0; j < 4; j++) { /*z_rotate*/
t = x.p[0], x.p[0] = x.p[1], x.p[1] = x.p[5];
x.p[5] = x.p[4], x.p[4] = t;
if(cmp(y, x) > 0) y = x;
}
t = x.p[1], x.p[1] = x.p[3], x.p[3] = x.p[4];
x.p[4] = x.p[2], x.p[2] = t;
if(cmp(y, x) > 0) y = x;
}
return y;
}
int main() {
char s[50], i;
Dice a, b;
while(gets(s)) {
for(i = 0; i < 6; i++)
a.p[i] = s[i], b.p[i] = s[i+6];
a = MinExp(a);
b = MinExp(b);
if(!memcmp(a.p, b.p, 6))
puts("TRUE");
else
puts("FALSE");
}
return 0;
}