当前位置:网站首页>uva11825
uva11825
2022-06-29 06:38:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = (1 << 16) + 7;
const int maxm = 20;
int n,m, around[maxm],cover[maxn],f[maxn];
int main()
{
int t,kCase = 1;
while (cin >> n && n) {
for (int i = 0; i < n; i++) {
cin >> m;
//当前位置周围有哪些计算机
around[i] = 1 << i;
for (int j = 0; j < m; j++) {
cin >> t;
around[i] |= 1 << t;
}
}
for (int i = 0; i < 1 << n; i++) {
cover[i] = 0;
//选取这些位置 能够覆盖哪些电脑
for (int j = 0; j < n; j++) {
if (i & (1 << j)) cover[i] |= around[j];
}
}
int target = (1 << n) - 1;
f[0] = 0;
for (int i = 1; i < 1 << n; i++) {
f[i] = 0;
for (int j = i; j; j = (j - 1) & i) {
if (cover[j] == target) f[i] = max(f[i], f[i ^ j] + 1);
}
}
cout << "Case " << kCase++ << ": " << f[target] << endl;
}
return 0;
}
边栏推荐
- Li Kou daily question - day 30 -1523 Number of bit 1
- Li Kou daily question - day 30 -1281 Difference of sum of bit product of integer
- Ribbon 服务调用与负载均衡
- 解析学习幼儿机器人教育的浪潮
- CI工具Jenkins之二:搭建一个简单的CI项目
- 大型化工企业数字化转型建议
- Database - Synonyms
- 关于端口转发程序的一点思考
- Crawler data analysis (introduction 2-re analysis)
- Character pointer as function parameter
猜你喜欢

Qt 程序打包发布-windeployqt工具

CI工具Jenkins之二:搭建一个简单的CI项目

大型化工企业数字化转型建议

JDBC连接数据库,socket发送客户端。

package.json的所有配置项及其用法,你都熟悉么

Move disassembly of exclusive delivery of script (the first time)

CI工具Jenkins安装配置教程

It is the only one in China that Alibaba cloud container service has entered the Forrester leader quadrant

Creating a new generation of production and service tools with robot education

Idea integrated code cloud
随机推荐
Idea integrated code cloud
Introduction to NoSQL database
QT custom bit operation class
About DDNS
And check the collection hello
Open source 23 things shardingsphere and database mesh have to say
Qt 程序打包发布-windeployqt工具
Introduction to Ceres Quartet
Qt QFileInfo简介
数据库-同义词
package. Are you familiar with all configuration items and their usage of JSON
CI工具Jenkins安装配置教程
Redistemplate handles hash integer type problem resolution
消息队列之通过幂等设计和原子锁避免重复退款
消息队列之通过队列批处理退款订单
多模态 —— Learnable pooling with Context Gating for video classification
Daily question 1 - force deduction - there are three consecutive arrays of odd numbers
Ribbon service invocation and load balancing
NoSQL数据库之Redis(四):Redis的发布和订阅
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事