CF986C

给\(A_i\)连一条向补集的边和子集的边,然后dfs求联通块数


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm> using namespace std; const int M = 7000001;
int n,m,k,f[M],s[25],N,g[M],d[M],a[M]; void dfs(int x)
{
if(f[x]) return ;
f[x]=1;
if(g[x]) dfs((1<<n)-1-x); for(int i=0;i<=n;i++) if(x&(1<<i)) dfs(x-(1<<i));
} int main()
{
scanf("%d%d",&n,&m);// N=m;
for(int i=1;i<=m;i++)
{
scanf("%d",&a[i]);
g[a[i]]=1;//g[(1<<n)-1-a[i]]=1;
} for(int i=1;i<=m;i++)
if(!f[a[i]]) dfs((1<<n)-1-a[i]),N++;
printf("%d",N);
}

CF986C的更多相关文章

  1. CF986C AND Graph

    半年前做的一道题现在还是不会 x&y=0 意味着,x的补集的子集都是和x直接相连的 不妨令图中的点数就是2^n 那么可以直接从x^((1<<n)-1)开始记忆化爆搜,路上遇到的都是 ...

  2. dfs套异或的包含性——cf986C好

    很好的题,想了半天,官方题解的解法更好 这种异或问题的包含性在北邮的校赛里就出现过,需要认真学习一下 /* y和所有合法的x合并,如果没有剪枝,那么复杂度爆炸总共要判(2^n*2^n) 可以考虑如下优 ...

  3. 在$CF$水题の记录

    CF1158C CF1163E update after CF1173 很好,我!expert!掉rating了!! 成为pupil指日可待== 下次要记得合理安排时间== ps.一道题都没写的\(a ...

随机推荐

  1. bstToDoublyList

    bstToDoublyList */--> code {color: #FF0000} pre.src {background-color: #002b36; color: #839496;} ...

  2. window.location.search 为何在url 带# 号时获取不到 ?

    我们在获取url参数时,会常常用到截取参数 getUrlParam(name) { const reg = new RegExp('(^|&)' + name + '=([^&]*)( ...

  3. 57.Queue Reconstruction by Height(按身高重建对列)

    Level:   Medium 题目描述: Suppose you have a random list of people standing in a queue. Each person is d ...

  4. git update-index --assume-unchanged on directory 转摘自:http://stackoverflow.com/questions/12288212/git-update-index-assume-unchanged-on-directory

    30down votefavorite 16 git 1.7.12 I want to mark all files below a given directory as assume-unchang ...

  5. Cas 使用maven的overlay搭建开发环境 (二)

    关于cas-server的安装.部署网上教程很多.但是使用Cas,只通过部署时修改配置是无法满足产品需求的,因此需要我们改造Cas.本文讲解如何使用maven的overlay无侵入的改造Cas. 什么 ...

  6. 【记录】linux docker 安装 tomcat

    前言:首先linux需要先安装docker,具体步骤可以参考博主之前博客,也可自行百度. 话不多说,开始安装tomcat: 通过docker安装tomcat docker pull tomcat:8. ...

  7. centos 搭建本地YUM源并使用apache共享YUM源

    搭建本地YUM源 1.挂载镜像 2.搭建本地YUM源 删除多余repo文件保留一个就行 本地YUM源就搭建好了 yum repolist 查看yum源 3.使用apache共享YUM源 YUM服务器配 ...

  8. java运算注意事项

    /* 对于byte.short.char.插入三种类型来说,如果右侧固执的数值没有超过范围,那么java编译器就会自动隐含地位我们 补上一个(byte) ,(short),(char) 1.如果没有超 ...

  9. 使用aop和BindingResult进行参数验证

    1.在需要校验的参数名上面添加注解 2.在web层接收参数(参数前面使用@Valid进行标记,后面必须紧跟参数bindingResult,存储参数的错误信息) 3.使用aop进行校验信息统一处理 @C ...

  10. 【leetcode】993. Cousins in Binary Tree

    题目如下: In a binary tree, the root node is at depth 0, and children of each depth k node are at depth  ...