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. 关于js与php互相传值的介绍【转载+自身总结】

    JS是前台的语言,PHP是后台的语言,初学时会经常出现前后台分不清的情况(我当初就是这样的,现在有时也在犯),我当初的想法是就把前后台当成两个岛,他们是无法跨越的,HTML就像一座桥,当你想要把一座岛 ...

  2. 网址、URL

    手册网:http://www.shouce.ren/ in_array().array_search().array_key_exists() http://www.shangxueba.com/ji ...

  3. java.util.regx Demo

    import java.util.regex.Matcher;import java.util.regex.Pattern; public class TestRegex { public stati ...

  4. 【JSP&Servlet学习笔记】5.Servlet进阶AIP、过滤器与监听器

    Servlet接口上,与生命周期及请求服务相关的三个方法是init().service()与destory()方法.当Web容器加载Servlet类并实例化之后,会生成ServletConfig对象并 ...

  5. hdu 5055 Bob and math problem

    先把各个数字又大到小排列,如果没有前导零并且为奇数,则直接输出.如果有前导零,则输出-1.此外,如果尾数为偶数,则从后向前找到第一个奇数,并把其后面的数一次向前移动,并把该奇数放到尾部. 值得注意的是 ...

  6. PXE安装linux系统

    利用网络安装系统流程:1.配置dhcp,让客户端能够自动获取ip,在dhcp配置中添加pxelinux.0配置,使客户端连接tftp文件2.复制光盘镜像的isolinux文件夹下面的所有文件到tftp ...

  7. lsof作用

    lsof 卸载移动存储时经常提示device busy,也可能误删了一个正在打开的文件....  这时候可以试试lsof  lsof简介 lsof(list open files)是一个列出当前系统打 ...

  8. [DevExpress]SplitContainerControl使用小计

    1.修改成纵向分割 Horizontal = false; 2.设置伸缩箭头 3.固定某个PANEL大小 最大化后依然保持着比例 4.隐藏某个PANEL splitContainerControl1. ...

  9. 发光的input框(纯css实现)

    css代码: input{width: 200px;height: 40px;} input.focus{border-color: #08c;box-shadow: 0 0 4px #8bd6fb; ...

  10. php之面向对象(1)

    讲到面向对象 先回顾下以前的编程思路,所谓编程思路就是根据知识本质原理通过逻辑推理程序的过程,编程思路,讲究的是先明确要做的事情是怎么.离开代码的情况下,自己也要能明白这一件事情怎么做.而不是把代码背 ...