It's a violent problem, but there are a lot of tricks and details.
This question:
1, familiar with the bitwise operator, feel different or operation of the force lattice has a higher level
2, you can use a number of 2 to represent the collection (this need to use multiple)
3, halfway meet law ... In fact, gross position's collection is split into two halves, reducing the exponent to make the violence solvable. (The Middle-South school race in the previous period, there seems to be a problem with this method)
#include <cstdio>#include<map>using namespacestd;Const intMAXN = -;intA[maxn];map<int,int>tab;intBITCNT (intx) { returnX?BITCNT (x>>1)+(1&X):0;}intMain () {//freopen ("In.txt", "R", stdin); intN; while(~SCANF ("%d",&N)) {Chars[1005]; for(inti =0; i<n;++i) {scanf ("%s", s); A[i]=0; for(intj =0; s[j]!=0; ++j) a[i]^= (1<< (s[j]-'A')); } tab.clear (); intN1 = n/2, N2 = nN1; for(inti =0;i< (1<<N1); + +i) {intx =0; for(intj =0; j<n1;++j)if(i& (1<<J)) x^=A[j]; if(!tab.count (x) | | bitcnt (TAB[X]) <bitcnt (i) tab[x] =i; } intAns =0; for(inti =0;i< (1<<N2); + +i) {intx =0; for(intj =0; j<n2;++j)if(i& (1<<J)) x^=a[j+N1]; if(Tab.count (x) && bitcnt (ans) <bitcnt (tab[x]) +bitcnt (i)) ans= tab[x]^ (i<<N1); } printf ("%d\n", bitcnt (ans)); for(inti =0; i<n;++i)if(ans& (1<<i)) printf ("%d", i+1); Puts (""); } return 0;}
LA 2965 Jurassic remains