Uva11825hackers ' crackdown

Source: Internet
Author: User

Exercises

First, the neighboring points are binary, save in P[i]

Then record the values of the different combinations of p[i] combinations and save them in Cover[i]

Then from small to large to carry out DP

S0 as a subset of the set S

if (cover[s0] = = all-1) F[s] = max (F[s], F[s ^ s0] + 1);

Code:

#include <bits/stdc++.h>using namespacestd;#definePB Push_back#defineMP Make_pair#defineSe Second#defineFS First#defineLson l,m,rt<<1#defineRson m+1,r,rt<<1|1#definePII pair<int,int>Const intINF =1000000000;Const intMAXN =1<< -;intN, m, X;intp[ -], cover[MAXN];intf[MAXN];intMain () {intCase =1;  while(~SCANF ("%d", &n) &&N) {memset (P,0,sizeof(p));  for(inti =0; I < n; i + +) {scanf ("%d", &m); p[i]= (1<<i);  while(M--) {scanf ("%d", &x); p[i]|= (1<<x); }        }        intall =1<<N;  for(ints =0; s < all; S + +) {cover[S]=0;  for(inti =0; I < n; i + + )            if(S & (1<< i)) cover[s] |=p[i]; }         for(ints =0; s < all; S + +) {f[S]=0;  for(intS0 = s; S0; S0 = (S0-1) &s) {if(cover[s0] = = All-1) f[S] = max (f[s], f[s ^ s0] +1 ); }} printf ("Case %d:%d\n", Case +, f[all-1 ] ); }    return 0;}

Uva11825hackers ' crackdown

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.