887C.md (1701B)
1 Source: https://codeforces.com/problemset/problem/887/C 2 3 C. Solution for Cube 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2. 22 23 It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction. 24 25 To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above. 26 27 Cube is called solved if for each face of cube all squares on it has the same color. 28 29 https://en.wikipedia.org/wiki/Rubik's_Cube 30 31 Input 32 33 In first line given a sequence of 24 integers *a**i* (1 ≤ *a**i* ≤ 6), where *a**i* denotes color of *i*-th square. There are exactly 4 occurrences of all colors in this sequence. 34 35 Output 36 37 Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise. 38 39 Examples 40 41 Input 42 43 ``` 44 2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4 45 ``` 46 47 Output 48 49 ``` 50 NO 51 ``` 52 53 Input 54 55 ``` 56 5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3 57 ``` 58 59 Output 60 61 ``` 62 YES 63 ``` 64 65 Note 66 67 In first test case cube looks like this: 68 69  70 71 In second test case cube looks like this: 72 73  74 75 It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.