CF986C.AND Graph

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a set of size mm with integer elements between 00 and 2n−12^{n}-1 inclusive. Let's build an undirected graph on these integers in the following way: connect two integers xx and yy with an edge if and only if x&y=0x \& y = 0. Here &\& is the bitwise AND operation. Count the number of connected components in that graph.

给你一个大小为 mm 的集合,其中元素为介于 00 和 2n−12^{n}-1(含)之间的整数。我们按如下方式在这些整数上构建一个无向图:当且仅当 x&y=0x \& y = 0 时,在整数 xx 和 yy 之间连一条边。这里 &\& 表示按位与运算。求该图中连通块的个数。

输入格式

In the first line of input there are two integers nn and mm (0≤n≤220 \le n \le 22, 1≤m≤2n1 \le m \le 2^{n}).

In the second line there are mm integers a1,a2,…,ama_1, a_2, \ldots, a_m (0≤ai<2n0 \le a_{i} \lt 2^{n}) — the elements of the set. All aia_{i} are distinct.

输入的第一行包含两个整数 nn 和 mm(0≤n≤220 \le n \le 22,1≤m≤2n1 \le m \le 2^{n})。

第二行包含 mm 个整数 a1,a2,…,ama_1, a_2, \ldots, a_m(0≤ai<2n0 \le a_{i} \lt 2^{n}),表示集合的元素。所有 aia_i 互不相同。

输出格式

Print the number of connected components.

输出连通分量的数量。

输入输出样例

  • 输入#1

    2 3
    1 2 3

    输出#1

    2
  • 输入#2

    5 5
    5 19 10 20 12

    输出#2

    2

说明/提示

Graph from first sample:

Graph from second sample:

第一个样例的图:

第二个样例的图:

输入解题思路,AI测评打分。不知道怎么写?

首页