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. 【刷题】BZOJ 4946 [Noi2017]蔬菜

    Description http://www.lydsy.com/JudgeOnline/upload/Noi2017D2.pdf Solution 网上大部分都是并查集写法,但是有大神写了非并查集写 ...

  2. Sublime Text Ctags 安装、使用、快捷键

    安装ctags应用程序. 1.到CTags的官方网站下载最新版本,将解压后的ctags.exe放到系统环境变量的搜索路径中.一般是C:\windows\system32. 如果你想放到其他文件夹中,记 ...

  3. jedisClient操作redis实现增删改查功能

    这个集群环境下和单机环境下: package com.taotao.sso.dao.impl; import org.springframework.beans.factory.annotation. ...

  4. python 爬虫 scrapy1_官网教程

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

  5. PAM认证机制详情

    PAM(Pluggable Authentication Modules)认证机制详情 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.      一.介绍PAM PAM(Plugga ...

  6. 浅说搜索引擎和SEO

    搜索引擎 基本工作原理 信息收集功能 技术点SEO优化核心 优化重点 SEO优化 网站URL title信息 meta信息 图片ALT flash信息 frame框架 网页重要度特征 之前有看到一个师 ...

  7. vue中的this指向问题

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 被误解的 Node.js

    http://www.ibm.com/developerworks/cn/web/1201_wangqf_nodejs/ 被误解的 Node.js

  9. Flex 自定义 Zlert 组件!

    说明: 原生的 Alert.show 参数,要显示的按钮你只能 Alert.OK | Alert.Cancel 这样; 自定义 Zlert 参数跟原生的 差不多,按钮写法是这样写的: {"b ...

  10. 【GDOI2018】所有题目和解题报告

    使用说明:题意和数据范围都只是回忆内容,仅供参考.题解陆续补上. Day 1 第一题 题意:给定n个数字,要求划分成k的连续段使得每个连续段内的数字之和相同,求最大的k.n,Σai<=10^6. ...