Uva 10601 Cubes Six-dimensional backpack +burnside lemma

Source: Internet
Author: User

Test Instructions:Link Method:Six-dimensional backpack +burnside lemma parsing:Very fun a Burnside/polya problem result I see since this problem has color limitations, then directly think of the card that problem. Got a backpack or something. There are 24 ways to rotate the cube. Face Center Rotation There are 4 4 4 displacement (90°) with 2 2, 2, 2 2 of Displacement (180°) has 2 4 4 of the displacement of the center rotation has 4 1 1 2 2 2 Displacement * 2 points symmetric rotation with 6 3 3 3 of the displacement of the next? How to determine the number of invariant permutations for each permutation of the small permutation group to choose the same color to meet. So on the 6-dimensional backpack. Of course, the number of useful combinations, but still 6-dimensional backpack cool. But if you drive a 12^6 backpack, it's going to be tough every time you memset. So what do you need to open? After we have counted 12 lengths of color and sorted by descending order, we find that the first dimension is <=12, the second dimension is <=6, the third dimension is <=4, the fourth dimension is <=3, and the other is <=2, and the six dimension is <=2. In this case, the backpack memory suddenly changed to more than 10,000, directly on the can. And the time is 10ms, easy to understand. Code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N f[j][k][ L][m][n][o]usingnamespaceStd;typedef Long Long Ll;ll f[ -][7][5][4][3][3];inta[7];int size[ the];intT,cnt;ll ans;void Backpack () {memset (f),0, sizeof (f)); f[0][0][0][0][0][0]=1; for(intI=1; i<=cnt;i++) for(intj=a[1];j>=0; j--) for(intk=a[2];k>=0; k--) for(intl=a[3];l>=0; l--) for(intm=a[4];m>=0; m--) for(intn=a[5];n>=0; n--) for(into=a[6];o>=0; o--) {if(j>=size[i]) n+=f[j-size[I]] K L [M] N [O];if(k>=size[i]) n+=f[j][k-size[I]] L [M] N [O];if(l>=size[i]) n+=f[j][k][l-size[I]] [M] N [O];if(m>=size[i]) n+=f[j][k][l][m-size[I]] N [O];if(n>=size[i]) n+=f[j][k][l][m][n-size[I]] [O];if(o>=size[i]) n+=f[j][k][l][m][n][o-size[i]]; }}void Solve () {size[1]=size[2]=size[3]=4; Cnt=3;    Backpack (); ans+=6*f[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]];size[1]=size[2]=size[3]=size[4]=size[5]=size[6]=2; Cnt=6;    Backpack (); ans+=3*f[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]];size[1]=size[2]=1,size[3]=size[4]=size[5]=size[6]=size[7]=2; Cnt=7;    Backpack (); ans+=6*f[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]];size[1]=size[2]=size[3]=size[4]=3; Cnt=4;    Backpack (); ans+=8*f[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]];size[1]=size[2]=size[3]=size[4]=size[5]=size[6]=1;size[7]=size[8]=size[9]=size[Ten]=size[ One]=size[ A]=1; Cnt= A;    Backpack (); ans+=f[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]];}intcmpintAintb) {returnA>b;}intMain () {scanf ("%d", &t); while(t--) {ans=0; Memset (A,0, sizeof (a));intX for(intI=1; i<= A; i++) scanf ("%d", &x), a[x]++;Sort(A +1, A +6+1, CMP);        Solve (); printf"%lld\n", ans/ -ll); }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Uva 10601 Cubes Six-dimensional backpack +burnside lemma

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.