LA 2965 Jurassic remains

Source: Internet
Author: User

  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&AMP;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&LT;&LT;N1); + +i) {intx =0;  for(intj =0; j<n1;++j)if(i& (1&LT;&LT;J)) x^=A[j]; if(!tab.count (x) | | bitcnt (TAB[X]) <bitcnt (i) tab[x] =i; }        intAns =0;  for(inti =0;i< (1&LT;&LT;N2); + +i) {intx =0;  for(intj =0; j<n2;++j)if(i& (1&LT;&LT;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

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.