Hackers’ Crackdown 

Input: Standard Input

Output: Standard Output

 

Miracle Corporations has a number of system services running in a distributed computer system which is a prime target for hackers. The system is basically a set of computer nodes with each of them running a set of services. Note that, the set of services running on every node is same everywhere in the network. A hacker can destroy a service by running a specialized exploit for that service in all the nodes.

One day, a smart hacker collects necessary exploits for all these services and launches an attack on the system. He finds a security hole that gives him just enough time to run a single exploit in each computer. These exploits have the characteristic that, its successfully infects the computer where it was originally run and all the neighbor computers of that node.

Given a network description, find the maximum number of services that the hacker can damage.

Input

There will be multiple test cases in the input file. A test case begins with an integer N (1<=N<=16), the number of nodes in the network. The nodes are denoted by 0 to N - 1. Each of the following lines describes the neighbors of a node. Line i (0<=i<N) represents the description of node i. The description for node starts with an integer (Number of neighbors for node i), followed by integers in the range of to N - 1, each denoting a neighboring node of node i.

The end of input will be denoted by a case with N = 0. This case should not be processed.

Output

For each test case, print a line in the format, “Case X: Y”, where X is the case number & Y is the maximum possible number of services that can be damaged.

Sample Input

1 3 6 7
1 7 5 4 8 3 9
1 4 3 5 6 2 8 9

Sample Output

Case 1: 3
Case 2: 2

状压DP、枚举子集

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define N (1<<16)+10 int n;
int p[];
int cover[N];
int dp[N]; int main()
{
int i,j,k,iCase=;
while(scanf("%d",&n),n)
{
for(i=;i<n;i++)
{
int m,x;
p[i]=<<i;
scanf("%d",&m);
while(m--)
{
scanf("%d",&x);
p[i]|=(<<x);
}
}
int MAX=<<n;
for(j=;j<MAX;j++)
{
cover[j]=;
for(i=;i<n;i++)
{
if(j&(<<i)) cover[j]|=p[i];
}
}
for(j=;j<MAX;j++) //枚举集合j
{
dp[j]=;
for(k=j;k;k=(k-)&j) //枚举子集k
{
if(cover[k]==MAX-) dp[j]=max(dp[j],dp[j^k]+);
}
}
printf("Case %d: %d\n",iCase++,dp[MAX-]);
}
return ;
}

[Uva 11825] Hackers’ Crackdown的更多相关文章

  1. UVA 11825 Hackers' Crackdown

    题目大意就是有一个图,破坏一个点同时可以破坏掉相邻点.每个点可以破坏一次,问可以完整破坏几次,点数=16. 看到16就想到状压什么的. 尝试设状态:用f[i]表示选的情况是i(一个二进制串),至少可以 ...

  2. UVA 11825 Hackers’ Crackdown(集合动态规划 子集枚举)

    Hackers’ Crackdown Miracle Corporations has a number of system services running in a distributed com ...

  3. UVA 11825 Hackers’ Crackdown 状压DP枚举子集势

    Hackers’ Crackdown Miracle Corporations has a number of system services running in a distributed com ...

  4. UVa 11825 - Hackers' Crackdown DP, 枚举子集substa = (substa - 1)&sta 难度: 2

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  5. UVa 11825 Hackers' Crackdown (状压DP)

    题意:给定 n 个计算机的一个关系图,你可以停止每台计算机的一项服务,并且和该计算机相邻的计算机也会终止,问你最多能终止多少服务. 析:这个题意思就是说把 n 台计算机尽可能多的分成一些组,使得每组的 ...

  6. UVA 11825 - Hackers&#39; Crackdown 状态压缩 dp 枚举子集

    UVA 11825 - Hackers' Crackdown 状态压缩 dp 枚举子集 ACM 题目地址:option=com_onlinejudge&Itemid=8&page=sh ...

  7. uva 11825 Hackers&#39; Crackdown (状压dp,子集枚举)

    题目链接:uva 11825 题意: 你是一个黑客,侵入了n台计算机(每台计算机有同样的n种服务),对每台计算机,你能够选择终止一项服务,则他与其相邻的这项服务都终止.你的目标是让很多其它的服务瘫痪( ...

  8. 【UVA】11825 Hackers' Crackdown(状压dp)

    题目 传送门:QWQ 分析 $ n<= 16 $ 显然是状压 然后搞一搞(靠着蓝书yy一下) 代码 #include <bits/stdc++.h> using namespace ...

  9. Hackers' Crackdown UVA - 11825

    Miracle Corporations has a number of system services running in a distributed computer system which ...

随机推荐

  1. 第12条:考虑实现Comparable接口

    CompareTo方法没有在Object中声明,它是Comparable接口中的唯一的方法,不但允许进行简单的等同性比较,而且允许执行顺序比较.类实现了Comparable接口,就表明它的实例具有内在 ...

  2. hdu 5000 Clone

    dp,用dp[i][j],表示和为i的前j个维度的种类.其中arr[i],表示第i维的最大值. 则\begin{equation} dp[i][j] = \sum_{0 \leq k \leq \mi ...

  3. post提交与get提交的一个小知识点

    今天偶然发现post提交与get提交的一个小知识点,记下来以后可以看看. 将form表单的method的设置为get后,通过url传递的参数将不会被传递到服务器,例如1.ashx?a=123,的a=1 ...

  4. 探究为何rem在chrome浏览器上计算出错

    最近在一个项目中,测试同学提了一个bug,说手机上有个页面的某些字体显示偏大.就像这样 我用chrome浏览器在pc上测试了一下,发现pc上也有这个问题,但是用其它浏览器打开这个页面就没有发现这个问题 ...

  5. JAVA 修改 JSESSIONID

    @Action("sidTest") public void sidTest() { HttpSession session = request.getSession(); Str ...

  6. 【InstallShield】 为什么卸载后有的文件没有删掉

    1.Component的属性Permanent设置为Yes. 2.Component的ID为空. 3.Component被其他应用程序或者Feature使用. 4.设置了一个Condition,在安装 ...

  7. 关于return和exit

    关于return和exit 在子进程退出的时候有两种方式,exit和exec族函数,不能使用return,为什么不能用return呢,exit改成return 会出现父子进程又各自重复开始进行. 1. ...

  8. GCC交叉编译链命名

    命名格式: arch[-vendor][-os]-abi arch:CPU的架构 vendor:工具链的供应商 os: 目标上运行的操作系统,不同的操作系统对应着不同的C库,例如 newlib.gli ...

  9. 我的PHP之旅--数组的认识(初级)

    数组 PHP的数组与swift有些许不同,分为3类(初级,以后会涉及到多维数组和数组指针等). 枚举数组 关联数组 混合数组 枚举数组 枚举数组跟swift中的数组差不多: <?php $arr ...

  10. java单例模式使用及注意事项

    1. 说明 1)单例模式:确保一个类只有一个实例,自行实例化并向系统提供这个实例 2)单例模式分类:饿单例模式(类加载时实例化一个对象给自己的引用),懒单例模式(调用取得实例的方法如getInstan ...