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