标签:string hacker scan clu rac ios ace print style
明早更新。
代码:
#include<iostream> #include<cstring> #include<algorithm> #include<stdio.h> #include<stdlib.h> #define MAXN 20 using namespace std; int n,m; int dp[1<<MAXN],cover[1<<MAXN],p[MAXN]; void cl(){ memset(p,0,sizeof(p)); memset(dp,0,sizeof(dp)); memset(cover,0,sizeof(cover)); } int main(){ int ca=0; while(1){ cl(); scanf("%d",&n); if(!n) break; for(int now=0;now<n;now++){ scanf("%d",&m); for(int i=1;i<=m;i++){ int x;scanf("%d",&x); p[now]|=1<<x; } p[now]|=1<<now; } int all=(1<<n)-1; for(int s=0;s<=all;s++){ for(int i=0;i<n;i++) if(s&(1<<i)) cover[s]|=p[i]; } for(int s=1;s<=all;s++){ for(int s0=s;s0;s0=(s0-1)&s){ if(cover[s0]==all) dp[s]=max(dp[s],dp[s^s0]+1); } } printf("Case %d: %d\n",++ca,dp[all]); } }
Hackers' Crackdown UVA - 11825
标签:string hacker scan clu rac ios ace print style
原文地址:http://www.cnblogs.com/renjianshige/p/7456101.html