题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2925
题目大意:


#include <bits/stdc++.h>
#define LL long long
using namespace std;

int p[20];
int cover[1<<20];
int f[1<<20];
int main()
{
    int n, T=1;
    while(scanf("%d", &n), n){
        
        //读入的处理
        memset(p, 0, sizeof(p));
        for(int i=0; i<n; i++){
            p[i]|=(1<<(i));
            int m;
            scanf("%d", &m);
            while(m--){
                int k;
                scanf("%d", &k);
                p[i]|=(1<<(k));
            }
        }

        //集合的集合并集
        for(int s=0; s<(1<<n); s++){
            cover[s]=0;
            for(int i=0; i<n; i++){
                if(s&(1<<i)){
                    cover[s]|=p[i];
                }
            }
        }

        //dp
        memset(f, 0, sizeof(f));
        int ALL=(1<<n)-1;
        for(int s=0; s<(1<<n); s++){
            for(int s0=s; s0; s0=(s0-1)&s){
                if(cover[s0]==ALL){
                    f[s]=max(f[s], f[s-s0]+1);
                }
            }
        }
        printf("Case %d: %d\n", T++, f[ALL]);
    }

    return 0;
}