"Parse" Burnside lemma + backpack dp+ multiplication inverse element
[Analysis]
This problem card for a long time, just do not want to understand the replacement followed by color is not the same.
According to the Burnside lemma, the number of non-equivalence classes under the action of a permutation group is the average number of fixed points under each permutation action.
In this question:
Displaced objects - Each state, labeled 1-n (n here is not the title n, but the number of States).
Fixed point -the number of states in which the dyeing state is exactly the same as before and after.
So it is to ask for the exact same number of States before and after the transformation.
[Sum]
Burnside lemma A few notes of the place
[1] What is the Burnside lemma?
[2] What is the permutation object?
[3] What does fixed point mean?
[4] The coloring transformation is not a permutation.
[Code]
<span style= "FONT-SIZE:18PX;" >/************************************************************** problem:1004 user:y20070316 language:c++ result:accepted time:328 Ms memory:2164 kb****************************************************************/#incl Ude <cstdio> #include <cstring> #include <cstdlib>using namespace std; const int n=70; int sr,sb,sg,n,m,p; Basicint map[n][n],d[n],v[n],cnt; Substitutionint F[n][n][n]; Damatic Programmingint Res; Answer inline int read (void) {int s=0,f=1; char C=getchar (); for (;c< ' 0 ' | | C> ' 9 '; C=getchar ()); for (; ' 0 ' <=c&&c<= ' 9 '; C=getchar ()) s=s*10+c-' 0 '; return s*f;} void init (void) {Sr=read (), Sb=read (), Sg=read (), N=SR+SB+SG; M=read (), P=read (); for (int. i=1;i<=m;i++) for (int j=1;j<=n;j++) map[i][j]=read (); m++; for (int j=1;j<=n;j++) map[m][j]=j;} void work (void) {for (int i=1;i<=m;i++) {cnt=0; memset (V,0,sizeof v); MemsET (d,0,sizeof D); for (int j=1;j<=n;j++) if (!v[j]) {v[j]=d[++cnt]=1; for (int k=map[i][j];k^j;k=map[i][k]) v[k]=1,d[cnt]++; } memset (f,0,sizeof f); F[0][0][0]=1; for (int i=1;i<=cnt;i++) for (int. j=sr;j>=0;j--) for (int k=sb;k>=0;k--) for (int q=sg;q>=0;q--) {f[j][k][q]=0; if (J>=d[i]) f[j][k][q]= (f[j][k][q]+f[j-d[i]][k][q])%p; if (K>=d[i]) f[j][k][q]= (f[j][k][q]+f[j][k-d[i]][q])%p; if (Q>=d[i]) f[j][k][q]= (f[j][k][q]+f[j][k][q-d[i])%p; } res= (RES+F[SR][SB][SG])%p; }} int mi (int i,int j) {if (!j) return 1; int S=mi (i,j>>1); s=s*s%p; if (j&1) s=s*i%p; return s;} void print (void) {int inv=mi (m,p-2); res=res*inv%p; printf"%d\n", (res+p)%p);} int main (void) {init (); Work (); Print (); return 0;} </span>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Bzoj" 1003 Cards