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 最大团的更多相关文章

  1. Codeforces Round #533 (Div. 2) E. Helping Hiasat(最大独立集)

    题目链接:https://codeforces.com/contest/1105/problem/E 题意:有 n 个事件,op = 1 表示我可以修改昵称,op = 2 表示一个名为 s_i 的朋友 ...

  2. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

  3. Codeforces Round #533 (Div. 2)

    C: 题意: 有n个整数ai,数列a有两个神奇的性质.1.所有的整数都在[l,r]范围内.2.这n个数的和能被3整除.现在给出l和r,和个数n,问你有多少种方法构造出数列a,方案数mod1e9+7. ...

  4. Codeforces Round #533 (Div. 2) Solution

    A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N ...

  5. Codeforces Round #533 (Div. 2) E 最大独立集

    知识点 最大独立集(set) = 补图的最大团(clique ) 最小顶点覆盖 + 最大独立集 = V E. Helping Hiasat time limit per test 2 seconds ...

  6. Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS

    题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #533(Div. 2) C.Ayoub and Lost Array

    链接:https://codeforces.com/contest/1105/problem/C 题意: 给n,l,r. 一个n长的数组每个位置可以填区间l-r的值. 有多少种填法,使得数组每个位置相 ...

随机推荐

  1. linux下转换windows文件格式为unix sed -i 's/\r//' <filename> 转化为unix格式

    sed -i 's/\r//' <filename> 转化为unix格式

  2. 【刷题】洛谷 P4782 【模板】2-SAT 问题

    题目背景 2-SAT 问题 模板 题目描述 有n个布尔变量 \(x_1\)​~\(x_n\)​,另有m个需要满足的条件,每个条件的形式都是"\(x_i\)​为true/false或\(x_j ...

  3. NOIP2018 No regrets youth

    NOIP2018在即,20181009总结一些易错的知识点和解题方法 ——by ljc20020730 HGOI NOIP2018 No regrets youth ! NOIP2018 No reg ...

  4. fzyzojP3979 -- [校内训练20180914]魔法方阵

    原题见CF632F https://blog.csdn.net/Steaunk/article/details/80217764 这个比较神仙了 点边转化, 把max硬生生转化成了路径最大值,再考虑所 ...

  5. 【codevs1245】最小的 N 个和

    题目大意:给定两个有 N 个数字的序列,从这两个序列中任取一个数相加,共有 \(N^2\) 个和,求这些和中最小的 N 个. 题解:由于数据量是 10W,必须减少每次选取的决策集合中元素的个数.可以发 ...

  6. git other-误删恢复等

    修改未push的最后一次commit 如在commit后发现漏添加的文件或者commit message需要修改,则可以依次执行: git add FILE_UN_STAGED # 将未提交的文件添加 ...

  7. Python序列化与反序列化-json与pickle

    Python序列化与反序列化-json与pickle 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.json的序列化方式与反序列化方式 1>.json序列化 #!/usr ...

  8. angularJs实现下拉框多选

    话不多说,直接上干货. 肯定需要下拉选插件.必须引入的是   注意 先后顺序 select2.css select2-bootstrap.css select2.min.js angular.min. ...

  9. CentOS6.8下安装Nginx-1.9.15

    1. 简介 Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器. Nginx是一款轻量级的Web服务器/反向代理服务器以及电子邮件代理服务器,并在一个BS ...

  10. Spring MVC 中 @ModelAttribute 注解的妙用

    Spring MVC 中 @ModelAttribute 注解的妙用 Spring MVC 提供的这种基于注释的编程模型,极大的简化了 web 应用的开发.其中 @Controller 和 @Rest ...