Cubes
题意
给出 12 12 12根长度相等的木棒,颜色最多有 6 6 6种,问能构成的本质不同的正方体数量.
题解
根据波利亚定理公式:
设X是元素集合,G是X的置换群, { u 1 , u 2 , . . . , u k } \{u_1,u_2,...,u_k\} {u1,u2,...,uk}是 k k k种颜色的集合, C C C是 X X X的任意着色集.这时,针对各颜色的数目的C的非等价着色数的生成函数是:
P G ( u 1 + . . . + u k , u 1 2 + . . . + u k 2 , . . . , u 1 n + . . . + u k n ) P_G{(u_1+...+u_k,u_1^2+...+u_k^2,...,u_1^n+...+u_k^n)} PG(u1+...+uk,u12+...+uk2,...,u1n+...+ukn)
-
我们先求出 12 12 12根木棒的颜色数,假设有 k k k中,每种颜色假设有 { c 1 , c 2 , . . . , c k } \{c_1,c_2,...,c_k\} {c1,c2,...,ck}个,注意 c 1 + . . . + c k = 12 c_1+...+c_k=12 c1+...+ck=12.
-
求出置换群.
众所周知的,正方体的置换群大小是 24 24 24.
(1)恒等变换: 1 1 1个
(2)绕对面的中心旋转 90 , 180 , 270 90,180,270 90,180,270度: 3 ∗ 3 = 9 3*3 = 9 3∗3=9个.
(3)绕对边的中点连成的轴旋转 180 180 180度: 6 ∗ 1 = 6 6*1 = 6 6∗1=6个.
(4)绕体对角线旋转 120 , 240 120,240 120,240度: 4 ∗ 2 = 8 4*2=8 4∗2=8个.
根据上述四种情况得到的关于线元素的置换平均值为:
P G = 1 24 ( z 1 12 + 6 z 4 3 + 3 z 2 6 + 8 z 3 4 + 6 z 1 2 z 2 5 ) P_G=\frac{1}{24}(z_1^{12}+6z_4^3+3z_2^6+8z_3^4+6z_1^2z_2^5) PG=241(z112+6z43+3z26+8z34+6z12z25) -
将 z i = ∑ u 1 i u 2 i . . . u 6 i z_i = \sum{u_1^iu_2^i...u_6^i} zi=∑u1iu2i...u6i代入 P G P_G PG式.那么答案就是 P G P_G PG函数的 u 1 c 1 u 2 c 2 . . . u k c k u_1^{c_1}u_2^{c_2}...u_k^{c_k} u1c1u2c2...ukck前的系数
-
P G P_G PG函数的每一项都是形如 ( u 1 + . . . + u k ) a ( u 1 2 + . . . + u k 2 ) b . . . ( u 1 n + . . . + u k n ) z (u_1+...+u_k)^{a}(u_1^2+...+u_k^2)^{b}...(u_1^n+...+u_k^n)^{z} (u1+...+uk)a(u12+...+uk2)b...(u1n+...+ukn)z的,我要对每个这样的式子,求 u 1 a u 2 b . . . u k z u_1^au_2^b...u_k^z u1au2b...ukz前的系数之和.每个项单独进行 d f s dfs dfs就可以了.
代码
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
#define pr(x) std::cout << #x << ':' << x << std::endl
#define rep(i,a,b) for(int i = a;i <= b;++i)
int T;
int tc[7],x[7],ox[7];
int C[13][13];
void init() {
C[0][0] = 1;
rep(i,1,12) {
C[i][0] = 1;
rep(j,1,i) {
C[i][j] = C[i-1][j] + C[i-1][j-1];
}
}
}
int ans = 0;
void dfs(int dep,int mul) {
if(dep == 5) {
int f = 0;
rep(i,1,6) f += x[i];
if(!f) {
ans += mul;
}
return ;
}
int tx[7];
rep(i,1,6) tx[i] = x[i];
for(int x1 = 0;x1 <= tc[dep] && dep * x1 <= tx[1];++x1) {
int res1 = C[tc[dep]][x1];
for(int x2 = 0;x2 <= tc[dep] - x1 && dep*x2 <= tx[2];++x2) {
int res2 = res1 * C[tc[dep]-x1][x2];
for(int x3 = 0;x3 <= tc[dep]-x1-x2 && dep*x3 <= tx[3];++x3) {
int res3 = res2 * C[tc[dep]-x1-x2][x3];
for(int x4 = 0;x4 <= tc[dep]-x1-x2-x3 && dep*x4 <= tx[4];++x4) {
int res4 = res3 * C[tc[dep]-x1-x2-x3][x4];
for(int x5 = 0;x5 <= tc[dep]-x1-x2-x3-x4 && dep*x5 <= tx[5];++x5) {
int res5 = res4 * C[tc[dep]-x1-x2-x3-x4][x5];
int x6 = tc[dep]-x1-x2-x3-x4-x5;
//pr(x1);pr(x2);pr(x3);pr(x4);pr(x5);pr(x6);
if(dep*x6 <= tx[6]) {
x[1] = tx[1] - dep*x1;x[2] = tx[2] - dep*x2;
x[3] = tx[3] - dep*x3;x[4] = tx[4] - dep*x4;
x[5] = tx[5] - dep*x5;x[6] = tx[6] - dep*x6;
dfs(dep+1,res5*mul);
}
}
}
}
}
}
}
int main() {
init();
std::ios::sync_with_stdio(false);
std::cin >> T;
while(T--) {
memset(ox,0,sizeof(ox));
rep(i,1,12) {
int tmp;
std::cin >> tmp;
ox[tmp] ++;
}
int res = 0;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = 12,tc[2] = tc[3] = tc[4] = 0;
dfs(1,1);
res += ans;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = tc[2] = tc[3] = 0,tc[4] = 3;
dfs(1,1);
res += 6*ans;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = tc[3] = tc[4] = 0,tc[2] = 6;
dfs(1,1);
res += 3*ans;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = tc[2] = tc[4] = 0,tc[3] = 4;
dfs(1,1);
res += 8*ans;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = 2,tc[2] = 5,tc[3] = tc[4] = 0;
dfs(1,1);
res += 6*ans;
std::cout << res/24 << std::endl;
}
return 0;
}