当前位置:网站首页>uva11825
uva11825
2022-06-29 07:15:00 【Stabbing the bear with a knife】
#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;
// Which computers are around the current location
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;
// Select these locations Which computers can be covered
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;
}
边栏推荐
- QT custom bit operation class
- jetson tx2
- 关于数据库,你应该知道的事情
- How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
- 转:侯宏:企业数字化转型的关键不是技术,而是战略
- NoSQL數據庫之Redis(五):Redis_Jedis_測試
- 【翻译】e-Cloud。使用KubeEdge的大规模CDN
- Error: GPG check FAILED Once install MySQL
- 大型化工企业数字化转型建议
- GenICam GenTL 标准 ver1.5(3)第四章
猜你喜欢
随机推荐
示波器 符号
NoSQL数据库之Redis(四):Redis的发布和订阅
Chinese garbled code on idea console [valid through personal test]
json tobean
Qt 容器类
idea控台中文乱码问题【亲测有效】
GenICam GenTL 标准 ver1.5(3)第四章
MIPS指令集与简要分析
About DDNS
When the soft keyboard appears, it makes my EditText field lose focus
Message queue batch processing refund order through queue
通过keyup监听textarea输入更改按钮样式
电子商务盛行,怎么提高商店转换率?
VerilogA - counter
Open source 23 things shardingsphere and database mesh have to say
NoSQL数据库之Redis(二):Redis配置文件介绍
Introduction to NoSQL database
Markdown 技能树(5):图片
idea使用
Error: GPG check FAILED Once install MySQL









