
1 //polya burnside定理 http://blog.csdn.net/liangzhaoyang1/article/details/72639208 2 //原题ASIA qingdao https://nanti.jisuanke.com/t/18515 3 #include <iostream> 4 #include <map> 5 #include <algorithm> 6 #include <cstring> 7 8 using namespace std; 9 10 map<string, bool> vis; 11 int tot; 12 const int LEN = 16; 13 int oo[3][LEN] = {//翻转 旋转 扭转 14 {0, 7, 2, 9, 4, 11, 6, 1, 8, 3, 10, 5, 12, 13, 15, 14}, 15 {13, 12, 4, 2, 5, 3, 15, 14, 9, 11, 8, 10, 6, 7, 0, 1}, 16 {1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 14, 15, 12, 13} 17 }; 18 bool cir[LEN+5]; 19 char sss[LEN+5]; 20 int cnts[LEN+5]={0}; 21 22 int cnt(string &s){ 23 int res = 0; 24 memset(cir,0,sizeof(cir)); 25 int f; 26 for(int i = 0; i < LEN; i++){ 27 if(!cir[i]){ 28 cir[i] = true; 29 f = i; 30 while(!cir[f = s[f]-'A']){ 31 cir[f] = true; 32 } 33 res++; 34 } 35 } 36 return res; 37 } 38 39 void bfs(string s){ 40 if(vis[s]) return; 41 tot++; 42 vis[s] = true; 43 cnts[cnt(s)]++; 44 string ss = s; 45 for(int i = 0; i < 3; i++){ 46 for(int k = 0; k < LEN; k++){ 47 s[k] = ss[oo[i][k]]; 48 } 49 bfs(s); 50 } 51 } 52 53 int main(){ 54 tot = 0; 55 for(int i = 0; i < LEN; i++) 56 sss[i] = i+'A'; 57 sss[LEN] = '