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. .NET和JSON

    JSON(JavaScript Object Notation)已经成为了现在大多数程序间数据交换的存储格式,在很多地方取代了XML文件的位置.JSON实际就是JavaScript的对象数组. .NE ...

  2. 模板:函数memcpy

    函数原型 void *memcpy(void *dest, const void *src, size_t n); 2功能 从源src所指的内存地址的起始位置开始拷贝n个字节到目标dest所指的内存地 ...

  3. Poj/OpenJudge 1042 Gone Fishing

    1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing ...

  4. php中位运算的应用:货品的状态

    效果如下图: 分析:用一个整数的二进制可以记录32状态 00000000 00000000 00000000 00000000  >>=0 从右往左保存这三个的状态: 精品选中,第一位设置 ...

  5. SQL技巧之分类汇总

    数据表结构username type numaaaa   玉米 1212aaaa   玉米  212bbb     小麦  2323bbb .... 只有两种产品 玉米和小麦,玉米价格1.5,小麦价格 ...

  6. 利用Keepalived+mysql构建高可用MySQL双主自动切转

    转载:http://www.it300.com/index.php/article-15266.html 关于MySQL-HA,目前有多种解决方案,比如heartbeat.drbd.mmm.共享存储, ...

  7. Sublime Text3快捷键一览表

    选择类 Ctrl+D 选中光标所占的文本,继续操作则会选中下一个相同的文本. Alt+F3 选中文本按下快捷键,即可一次性选择全部的相同文本进行同时编辑.举个栗子:快速选中并更改所有相同的变量名.函数 ...

  8. Chrome 浏览器各版本下载大全

    随着最近64位版本的 Chrome 浏览器正式版的推出,Chrome 浏览器再次受到广大浏览迷的重点关注,今天我们就整理一下各版本的 Chrome 浏览器 32位及64位的下载地址,方便各位浏览迷选择 ...

  9. Erlang 开发者的福音:IntelliJ IDEA 的 Erlang 插件

    IntelliJ IDEA 的 Erlang 插件,主要特性: 智能编辑器:  Erlang 代码补全.语法和错误高亮.代码检查 代码导航:项目和文件结构视图.在文件.模型.函数和用例之间快速跳转 工 ...

  10. MVC 中 使用TagBuilder扩展HtmlHelper

    TagBuilder就是标签建造器,我们就用它来建造属于我们自己标签生成函数. 无废话,直接上代码 例: using System.Web.Mvc; public static class HtmlE ...