这个题比较套路,貌似cls给noip模拟赛出过相同的题。。orznoip什么时候这么难了啊qaq

然后这个关键问题就在建图了,由于直接连边数太多,必须考虑将边的规模压缩。。

然后方法就是对每个数i向去掉其中一个1后的数连边(这里都是单向边),最多n条边。。然后如果出现了数组中存在的数。。那么就向反转后的数连边。。

然后发现这么连可以将x&y的点都给连起来。。而那些不在一个块上的是连不到的。。

然后直接乱搜就行了。。复杂度O(n*2^n)

其实最近出了挺多这样的题的。。上次NCPC的D也是一样。。

所以建图可以考虑这么一个思路,于只对某位做位运算后得到的点连边。。



/**
*         ┏┓    ┏┓
*         ┏┛┗━━━━━━━┛┗━━━┓
*         ┃       ┃  
*         ┃   ━    ┃
*         ┃ >   < ┃
*         ┃       ┃
*         ┃... ⌒ ...  ┃
*         ┃ ┃
*         ┗━┓ ┏━┛
*          ┃ ┃ Code is far away from bug with the animal protecting          
*          ┃ ┃ 神兽保佑,代码无bug
*          ┃ ┃           
*          ┃ ┃       
*          ┃ ┃
*          ┃ ┃           
*          ┃ ┗━━━┓
*          ┃ ┣┓
*          ┃ ┏┛
*          ┗┓┓┏━━━━━━━━┳┓┏┛
*           ┃┫┫ ┃┫┫
*           ┗┻┛ ┗┻┛
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 5000005
#define nm 5000005
#define pi 3.1415926535897931
const ll inf=1000000007;
using namespace std;
ll read(){
ll x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f*x;
}


int a[NM],n,m,tot,s;
bool v[NM],b[NM];
void dfs(int x){
if(v[x])return;
v[x]++;
if(b[x])dfs(tot-x);
inc(i,1,n)if(succ(i-1)&x)dfs(succ(i-1)^x);
}

int main(){
n=read();m=read();tot=succ(n)-1;
inc(i,1,m)b[a[i]=read()]++;
inc(i,1,m)if(!v[a[i]])dfs(a[i]),s++;
return 0*printf("%d\n",s);
}





C. AND Graph


time limit per test

4 seconds



memory limit per test

256 megabytes



input

standard input



output

standard output


You are given a set of size m

with integer elements between

0 and 2n−1 inclusive. Let's build an undirected graph on these integers in the following way: connect two integers x and y with an edge if and only if x&y=0. Here &

is the ​​bitwise AND operation​​. Count the number of connected components in that graph.

Input


In the first line of input there are two integers n

and

m ( 0≤n≤22, 1≤m≤2n

).

In the second line there are m

integers

a1,a2,…,am ( 0≤ai<2n) — the elements of the set. All ai

are distinct.

Output


Print the number of connected components.

Examples


Copy


2 3 1 2 3


Copy


2


Copy


5 5 5 19 10 20 12


Copy


2

Note


Graph from first sample:

codeforces485C(位运算->建图)_#include

Graph from second sample:

codeforces485C(位运算->建图)_#include_02