forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniquedice.cpp
77 lines (63 loc) · 1.15 KB
/
uniquedice.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
using namespace std;
string up(string s) {
int t = s[0];
s[0] = s[2];
s[2] = s[1];
s[1] = s[3];
s[3] = t;
return s;
}
string ri(string s) {
int t = s[2];
s[2] = s[5];
s[5] = s[3];
s[3] = s[4];
s[4] = t;
return s;
}
string fr(string s) {
int t = s[0];
s[0] = s[5];
s[5] = s[1];
s[1] = s[4];
s[4] = t;
return s;
}
string re(string s) {
unordered_set<string> v;
queue<string> q;
q.push(s);
while(!q.empty()) {
string curr = q.front();
q.pop();
if(v.count(curr)) continue;
v.insert(curr);
q.push(ri(curr));
q.push(up(curr));
q.push(fr(curr));
}
string best = "999999";
for(auto& i : v) {
best = min(best, i);
}
return best;
}
int main() {
int n;
cin >> n;
unordered_map<string,int> m;
for(int i = 0; i < n; i++) {
string s = " ";
for(auto& j : s) {
cin >> j;
}
s = re(s);
m[s]++;
}
int best = 1;
for(auto i : m) {
best = max(best, i.second);
}
cout << best << endl;
}