Codeforces Round #533 (Div. 2) E - Helping Hiasat 最大团
裸的最大团,写了一种 2 ^ (m / 2) * (m / 2)的复杂度的壮压, 应该还有更好的方法。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 2e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = ;
const double eps = 1e-; int n, m, op;
LL e[];
int a[<<], b[<<];
string name;
set<int> Set;
map<string, int> Map; int main() {
cin >> n >> m;
for(int i = ; i <= n; i++) {
cin >> op;
if(op == ) {
Set.clear();
} else {
cin >> name;
if(Map.find(name) == Map.end())
Map[name] = SZ(Map);
int x = Map[name];
for(auto& y : Set) {
e[x - ] |= 1ll << (y - );
e[y - ] |= 1ll << (x - );
}
Set.insert(x);
}
}
int c1 = m / , c2 = m - c1;
for(int S = ; S < ( << c1); S++) {
int p = __builtin_ctz(S), tmp = ;
a[S] = max(a[S], a[S ^ ( << p)]);
for(int i = ; i < c1; i++)
if(!(e[p]>>i&)) tmp |= << i;
a[S] = max(a[S], a[tmp & (S ^ ( << p))] + );
}
for(int S = ; S < ( << c2); S++) {
int p = __builtin_ctz(S), tmp = ;
b[S] = max(b[S], b[S ^ ( << p)]);
for(int i = ; i < c2; i++)
if(!(e[p + c1]>>(i+c1)&)) tmp |= << i;
b[S] = max(b[S], b[tmp & (S ^ ( << p))] + );
}
int ans = ;
for(int S = ; S < ( << c2); S++) {
LL tmp = ;
for(int i = ; i < c2; i++)
if(S >> i & ) tmp |= e[i + c1];
for(int i = ; i < c1; i++) tmp ^= << i;
tmp &= ( << c1) - ;
ans = max(ans, b[S] + a[tmp]);
}
printf("%d\n", ans);
return ;
} /*
*/
Codeforces Round #533 (Div. 2) E - Helping Hiasat 最大团的更多相关文章
- Codeforces Round #533 (Div. 2) E. Helping Hiasat(最大独立集)
题目链接:https://codeforces.com/contest/1105/problem/E 题意:有 n 个事件,op = 1 表示我可以修改昵称,op = 2 表示一个名为 s_i 的朋友 ...
- Codeforces Round #533 (Div. 2)题解
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...
- Codeforces Round #533 (Div. 2)
C: 题意: 有n个整数ai,数列a有两个神奇的性质.1.所有的整数都在[l,r]范围内.2.这n个数的和能被3整除.现在给出l和r,和个数n,问你有多少种方法构造出数列a,方案数mod1e9+7. ...
- Codeforces Round #533 (Div. 2) Solution
A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N ...
- Codeforces Round #533 (Div. 2) E 最大独立集
知识点 最大独立集(set) = 补图的最大团(clique ) 最小顶点覆盖 + 最大独立集 = V E. Helping Hiasat time limit per test 2 seconds ...
- Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...
- Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array 【dp】
传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 secon ...
- Codeforces Round #533 (Div. 2) B. Zuhair and Strings 【模拟】
传送门:http://codeforces.com/contest/1105/problem/B B. Zuhair and Strings time limit per test 1 second ...
- Codeforces Round #533(Div. 2) C.Ayoub and Lost Array
链接:https://codeforces.com/contest/1105/problem/C 题意: 给n,l,r. 一个n长的数组每个位置可以填区间l-r的值. 有多少种填法,使得数组每个位置相 ...
随机推荐
- 【刷题】清橙 A1339 JZPLCM(顾昱洲)
试题来源 2012中国国家集训队命题答辩 问题描述 给定一长度为n的正整数序列a,有q次询问,每次询问一段区间内所有数的lcm(即最小公倍数).由于答案可能很大,输出答案模1000000007. 输入 ...
- 洛谷P3348 [ZJOI2016]大森林(LCT,虚点,树上差分)
洛谷题目传送门 思路分析 最简单粗暴的想法,肯定是大力LCT,每个树都来一遍link之类的操作啦(T飞就不说了) 考虑如何优化算法.如果没有1操作,肯定每个树都长一样.有了1操作,就来仔细分析一下对不 ...
- 以 BZOJ 2002 为例学习有根树LCT(Link-Cut Tree)
以BZOJ 2002 弹飞绵羊为例学习有根树LCT(Link-Cut Tree) 注:本文非常简单,只涉及有根树LCT,对于无根树,LCT还有几个本文没有提到的操作,以后慢慢更新 =v= 知识储备 [ ...
- diyiti.cpp
diyiti.cpp/c/pas diyiti.in diyiti.out 2s/256MB 给定两个01串,S,T(下标从0开始). 支持如下3种操作: 1. 修改S第i位的字符,即0->1, ...
- 解题:UOJ #46 玄学
题面 二进制分组,修改把区间拆开丢在后面,合并的时候归并最后两块:查询在对应节点上二分答案 #include<cstdio> #include<cstring> #includ ...
- 图形化调试工具DDD
ubuntu安装DDD: sudo apt-get install ddd If you still need to compile it for some reason you should be ...
- info replication
主Redis设置值:redis-cli -h 192.168.18.121 -p 63800 -a tinywan123456 登陆从1:redis-cli -h 192.168.18.121 -p ...
- python assert 断言语句的作用
python assert 断言语句的作用 assert语句的应用场景 使用assert语句是一个很好的习惯. 我们在编写代码的时候, 不知道程序会在什么时候崩溃, 与其让它在深度运行时崩溃, 不如预 ...
- 控制台console对象常用的一些方法
console.log():调试中最常用的方法,用于在控制台窗口显示信息. console.log(123); console.warn():输出信息时,在最前面加一个黄色三角,表示警告 consol ...
- ASP.NET记录错误日志的方式
程序记录错误日志是一种看起来对一般用户没什么作用,但对程序开发者用处很大的东西,它能查出错误或异常的程序马迹.那么,常用的记录错误日志的方式有哪些呢? 大多数情况下使用的是 1.直接记录为txt/xm ...