2725.图的连通分量1

通过数:8提交数:11学校:中南大学保研机试真题 题目列表 标签
题目描述 graph's connected componentsGiven an integers set of m integers,each integer is in the range [0, 2n-1]. A graph is build on the following constraints: if integers X and Y satisfy X&Y=0 (& is bitwise AND operation),X and Y are connected by an undirected edge.Please help PIPI count the number of connected components in the graph! 给定一个包含 $m$ 个整数的集合,每个整数的范围在 $[0, 2^n-1]$ 内。 构建一个图:如果整数 $X$ 和 $Y$ 满足 $X \& Y = 0$($\&$ 是按位与操作),则 $X$ 和 $Y$ 之间有一条无向边。 请帮助 PIPI 计算图中连通分量的数量! 输入格式 输入包含多个测试用例。 每个测试用例以两个整数 $n$ ($0 \le n \le 22$) 和 $m$ ($1 \le m \le 2^n$) 开始。 下一行包含 $m$ 个不同的整数:$a 1, a 2, ..., a m$,每个整数 $0 \le a i < 2^n$。 输出格式 对于每个测试用例,输出连通分量的数量。 数据范围 $0 \le n \le 22$ $1 \le m \le 2^n$ 整数范围 $[0, 2^n-1]$ 输入样例1 2 3 1 2 3 5 5 5 19 10 20 12 5 6 5 19 10 20 12 0 输出样例1 2 2 1
C
补全
点击调试按钮即可调试代码。

点击提交按钮即可提交代码。