ural 1433. Diamonds
1433. Diamonds
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Sasha is lucky to have a diamond in the form of a regular tetrahedron. Incidentally, his friend Pasha has got a diamond of exactly the same shape and size. In order to distinguish between their diamonds, the friends decided to paint the crystals. Each of them painted each face of his diamond a certain color. The diamonds became very beautiful, so Pasha and Sasha were happy. But their happiness did not last long. That night, Sasha woke up with a sudden thought — what if his and Pasha's diamonds are still indistinguishable? He decided to call Pahsa immediately. Sasha ran up to the phone, tried to grasp the receiver, but at that moment the phone rang. Of course, it was Pasha, who had the same sudden thought. So Sasha and Pasha hastened to tell each other the colors of their diamonds' faces… Their worst fears were confirmed. Their diamonds were identical, and to see it one simply had to turn one of the diamonds.
You are to write a program that could prevent this horrible mistake. Given a scheme of the supposed coloring of the diamonds, determine if these colorings are identical, i.e., if one of them can be obtained from the other by turning the crystal.
Input
The input contains two lines. Each line contains four letters, which denote the colors of the faces in the following order: the base face, the "left front" face, the "right front" face, and the back face. There are only four paints available: red, green, blue, and yellow, denoted by the letters R, G, B, and Y, respectively.
Output
Output the word "equal" if the colored tetrahedrons will be identical, and the word "different" otherwise.
Sample
| input | output |
|---|---|
RGRB GRRB |
equal |
Problem Author: Pavel Egorov, Stanislav Vasilyev
Problem Source: The 7th USU Open Personal Contest - February 25, 2006
Problem Source: The 7th USU Open Personal Contest - February 25, 2006
Tags: none
Difficulty: 252
题意:给两个正四面的的四个面的颜色,判断两个四面体是否相等。
分析:所以我们只要将所有匹对方式打个表就好。
1 /** 2 Create By yzx - stupidboy 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <cstdlib> 7 #include <cmath> 8 #include <deque> 9 #include <vector> 10 #include <queue> 11 #include <iostream> 12 #include <algorithm> 13 #include <map> 14 #include <set> 15 #include <ctime> 16 #include <iomanip> 17 using namespace std; 18 typedef long long LL; 19 typedef double DB; 20 #define For(i, s, t) for(int i = (s); i <= (t); i++) 21 #define Ford(i, s, t) for(int i = (s); i >= (t); i--) 22 #define Rep(i, t) for(int i = (0); i < (t); i++) 23 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--) 24 #define rep(i, x, t) for(int i = (x); i < (t); i++) 25 #define MIT (2147483647) 26 #define INF (1000000001) 27 #define MLL (1000000000000000001LL) 28 #define sz(x) ((int) (x).size()) 29 #define clr(x, y) memset(x, y, sizeof(x)) 30 #define puf push_front 31 #define pub push_back 32 #define pof pop_front 33 #define pob pop_back 34 #define ft first 35 #define sd second 36 #define mk make_pair 37 inline void SetIO(string Name) 38 { 39 string Input = Name+".in", 40 Output = Name+".out"; 41 freopen(Input.c_str(), "r", stdin), 42 freopen(Output.c_str(), "w", stdout); 43 } 44 45 46 inline int Getint() 47 { 48 int Ret = 0; 49 char Ch = ' '; 50 bool Flag = 0; 51 while(!(Ch >= '0' && Ch <= '9')) 52 { 53 if(Ch == '-') Flag ^= 1; 54 Ch = getchar(); 55 } 56 while(Ch >= '0' && Ch <= '9') 57 { 58 Ret = Ret * 10 + Ch - '0'; 59 Ch = getchar(); 60 } 61 return Flag ? -Ret : Ret; 62 } 63 64 const int N = 12, M = 4; 65 int Face[12][4]={ 66 {0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, 67 {1, 2, 0, 3}, {1, 0, 3, 2}, {1, 3, 2, 0}, 68 {2, 0, 1, 3}, {2, 1, 3, 0}, {2, 3, 0, 1}, 69 {3, 2, 1, 0}, {3, 1, 0, 2}, {3, 0, 2, 1} 70 }; 71 struct Node 72 { 73 int Arr[4]; 74 inline void Read() 75 { 76 string Str; 77 cin >> Str; 78 Rep(i, 4) Arr[i] = Str[i]; 79 } 80 } A, B; 81 82 inline void Input() 83 { 84 A.Read(); 85 B.Read(); 86 } 87 88 inline void Solve() 89 { 90 Rep(i, 12) 91 { 92 bool Flag = 0; 93 Rep(j, 4) 94 if(A.Arr[Face[i][j]] != B.Arr[j]) 95 { 96 Flag = 1; 97 break; 98 } 99 if(!Flag) 100 { 101 puts("equal"); 102 return; 103 } 104 } 105 puts("different"); 106 } 107 108 int main() 109 { 110 #ifndef ONLINE_JUDGE 111 SetIO("B"); 112 #endif 113 Input(); 114 Solve(); 115 return 0; 116 }

浙公网安备 33010602011771号