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. Java实战之02Hibernate-08二级缓存

    十四.Hibernate的二级缓存 1.Hibernate的缓存结构 2.由于二级缓存被多线程共享,就必须有一定的事务访问策略 非严格读写:READ UNCOMMITTED 读写型:READ COMM ...

  2. C语言 宏/macor/#define/

    C语言 宏/macor/#define 高级技巧 1.在进行调试的时候,需要进行打印/PRINT,可以通过define进行自定义.例如,自己最常用的DEBUG_PRINT() #define DEBU ...

  3. linux下搭建nginx+php(FastCGI)+mysql运行环境

    一.安装环境 1.CentOS5.5 2.php5.4 3.MySQL5.5.19 二.安装程序依赖库和开发环境 为了省事把所需要的库文件全都安装上,可以使用rpm包安装,也可以用yum命令安装, 1 ...

  4. win7 蛋疼的时间格式转化

    win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:s ...

  5. 设置Session的超时时间

    设置Session的超时时间 IIS 里面有个设置 站点属性->主目录->应用程序配置->选项->启用会话状态->会话超时,可以设置. 在web.config中,设置: ...

  6. spring-boot 整合redis作为数据缓存

    添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...

  7. 有关C++ std::string 类的类型转换 其他语言永远无法理解的伤

    最近做了个项目,C++的MFC窗口程序,一个基于dialog的学生-图书管理系统,有一些感触,最后会放上一些项目截图和部分代码提供大家参考.如果有什么好方法和建议欢迎指导. 强类型,为什么这么伤 我知 ...

  8. div重叠不变形

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  9. PHP学习笔记(3) - 奇怪的class与autoload

    PHP的class与其他语言有很多不同点.PHP允许很奇葩的在静态方法中调用实例方法,提供了关键字self和static用于访问类自身的静态成员.self永远是指当前的类,而static则可能会变成指 ...

  10. iOS 7隐藏statusbar

    - (BOOL)prefersStatusBarHidden { return YES; } [[UIApplication sharedApplication] setStatusBarHidden ...