-
Notifications
You must be signed in to change notification settings - Fork 24
/
burnside.cpp
60 lines (50 loc) · 1.15 KB
/
burnside.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
#include <bits/stdc++.h>
using namespace std;
// computes number of cube colorings with k colors
int binpow (int a, int n) {
int ans = 1;
while (n) {
if (n&1) ans *= a;
a *= a;
n >>= 1;
}
return ans;
}
const int k = 3, n = 6;
vector<int> multiply (vector<int> a, vector<int> b) {
vector<int> ans(n);
for (int i = 0; i < n; i++)
ans[i] = a[b[i]];
return ans;
}
int cycles (vector<int> a) {
bool used[n] = {0};
int ans = 0;
for (int i = 0; i < n; i++) {
if (!used[i]) {
ans++;
int p = i;
while (!used[p]) {
used[p] = 1;
p = a[p];
}
}
}
return ans;
}
int main () {
set< vector<int> > s;
s.insert({0, 1, 2, 3, 4, 5});
vector<int> p1 = {0, 1, 3, 4, 5, 2},
p2 = {2, 4, 1, 3, 0, 5};
for (int l = 0; l < 6; l++) {
set< vector<int> > t = s;;
for (auto p : t)
s.insert(multiply(p, p1)), s.insert(multiply(p, p2));
}
int ans = 0;
for (auto p : s)
ans += binpow(k, cycles(p));
cout << ans / s.size();
return 0;
}