cf987f AND Graph

#include <iostream>
#include <cstdio>
using namespace std;
int n, uu, m;
bool a[4500005], vis[4500005][2];
void dfs(int x, int y){
if(vis[x][y]) return ;
vis[x][y] = true;
if(y==1) dfs(x, 2);
else{
for(int i=0; i<n; i++)
if(!(x&(1<<i)))
dfs(x|(1<<i), 2);
if(a[(1<<n)-1-x]) dfs((1<<n)-1-x, 1);
}
}
int main(){
cin>>n>>m;
for(int i=1; i<=m; i++){
scanf("%d", &uu);
a[uu] = true;
}
int ans=0;
for(int i=0; i<(1<<n); i++)
if(a[i] && !vis[i][1]){
dfs(i, 1);
ans++;
}
cout<<ans<<endl;
return 0;
}
cf987f AND Graph的更多相关文章
- [开发笔记] Graph Databases on developing
TimeWall is a graph databases github It be used to apply mathematic model and social network with gr ...
- Introduction to graph theory 图论/脑网络基础
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...
- POJ 2125 Destroying the Graph 二分图最小点权覆盖
Destroying The Graph Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8198 Accepted: 2 ...
- [LeetCode] Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...
- [LeetCode] Graph Valid Tree 图验证树
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...
- [LeetCode] Clone Graph 无向图的复制
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...
- 讲座:Influence maximization on big social graph
Influence maximization on big social graph Fanju PPT链接: social influence booming of online social ne ...
- zabbix利用api批量添加item,并且批量配置添加graph
关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个ho ...
- Theano Graph Structure
Graph Structure Graph Definition theano's symbolic mathematical computation, which is composed of: A ...
随机推荐
- 【luogu P3369 【模板】普通平衡树(Treap/SBT)】 模板 Scapegoat Tree
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> ...
- kinect v2
http://www.tuicool.com/articles/NbmyyeU https://channel9.msdn.com/Blogs/raw-tech/Making-your-body-th ...
- 菜鸟崛起 Ajax
AJAX概述 1 什么是AJAX AJAX(Asynchronous Javascript And XML)翻译成中文就是“异步Javascript和XML”.即使用Javascript语言与服务器进 ...
- maven pom 增加本地jar 依赖
https://www.cnblogs.com/huhongy/p/7337280.html <dependency> <groupId>org.hamcrest</gr ...
- linux ccenteros 部署 redis
step one : yum install redis -- 安装redis数据库 step two:安装完成之后开启redis 服务 service redis start syste ...
- HIbernate jar包
密码nbbk https://pan.baidu.com/share/init?surl=nYNO1f20FWMQiZ7iN11DIA
- Excel导入功能(Ajaxfileupload)
前言: 前端采用Easyui+Ajaxfileupload实现 后端采用springmvc框架,其中把解析xml封装成了一个jar包,直接调用即可 准备: 前端需要导入(easyui导入js省略,自行 ...
- ETO的公开赛T2《宏聚变》 题解(BY 萌萌哒123456 )
我们注意到这道题中最多有 $(n+q)$ 个数被加入,而每个数最多被删除一次,因此每次操作 $O(logn)$的复杂度是可以接受的. 我们对于$1..100000$之间每个数分别开一个set,维护这个 ...
- c++stl应用入门
在这篇中,我会讲几个简单易懂且比较常用的stl函数,这些函数在noip系列考试中往往被允许使用(既然让用我们自然不用手码了...) (末尾有惊喜!) 1.sort 绝大部分刚入门的oier第一个接触的 ...
- MyBatis模糊查询的三种拼接方式
1. sql中字符串拼接 SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%'); 2. 使用 ${...} ...