CF1775B.Gardener and the Array

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The gardener Kazimir Kazimirovich has an array of nn integers c1,c2,…,cnc_1, c_2, \dots, c_n.

He wants to check if there are two different subsequences aa and bb of the original array, for which f(a)=f(b)f(a) = f(b), where f(x)f(x) is the bitwise OR of all of the numbers in the sequence xx.

A sequence qq is a subsequence of pp if qq can be obtained from pp by deleting several (possibly none or all) elements.

Two subsequences are considered different if the sets of indexes of their elements in the original sequence are different, that is, the values of the elements are not considered when comparing the subsequences.

园丁卡西米尔·卡西米罗维奇有一个包含 nn 个整数的数组 c1,c2,…,cnc_1, c_2, \dots, c_n。

他想检查原数组中是否存在两个不同的子序列 aa 和 bb,使得 f(a)=f(b)f(a) = f(b),其中 f(x)f(x) 表示序列 xx 中所有数字的按位或结果。

若序列 qq 可通过从序列 pp 中删除若干(可能为零个、部分或全部)元素得到,则称 qq 是 pp 的一个子序列。

当且仅当两个子序列在原数组中所对应元素的下标集合不同时,才认为它们是不同的;即,在比较子序列时,不考虑元素的具体数值。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1051 \le t \le 10^5). The description of the test cases follows.

The first line of each test case contains one integer nn (1≤n≤1051 \le n \le 10^5) — the size of the array cc.

The description of the array cc in this problem is given implicitly to speed up input.

The (i+1)(i + 1)-st of the following nn lines of the test case begins with an integer kik_i (1≤ki≤1051 \le k_i \le 10^5) — the number of set bits in the number cic_i. Next follow kik_i distinct integers pi,1,pi,2,…,pi,kip_{i, 1}, p_{i, 2}, \dots, p_{i, k_i} (1≤pi≤2⋅1051 \le p_i \le 2 \cdot 10^5) —the numbers of bits that are set to one in number cic_i. In other words, ci=2pi,1+2pi,2+…+2pi,kic_i = 2^{p_{i, 1}} + 2^{p_{i, 2}} + \ldots + 2^{p_{i, k_i}}.

It is guaranteed that the total sum of kik_i in all tests does not exceed 10510^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1051 \le t \le 10^5)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5)—— 数组 cc 的大小。

本题中,数组 cc 的描述以隐式方式给出,以加快输入速度。

该测试用例接下来的 nn 行中,第 (i+1)(i + 1) 行首先是一个整数 kik_i(1≤ki≤1051 \le k_i \le 10^5)—— 表示数字 cic_i 的二进制表示中为 1 的位数(即“置位比特数”)。随后是 kik_i 个互不相同的整数 pi,1,pi,2,…,pi,kip_{i, 1}, p_{i, 2}, \dots, p_{i, k_i}(1≤pi≤2⋅1051 \le p_i \le 2 \cdot 10^5)—— 表示 cic_i 中值为 1 的那些比特位的编号(从最低位起编号为 1)。换言之,ci=2pi,1+2pi,2+…+2pi,kic_i = 2^{p_{i, 1}} + 2^{p_{i, 2}} + \ldots + 2^{p_{i, k_i}}。

保证所有测试用例中 kik_i 的总和不超过 10510^5。

输出格式

For each set of input, print "Yes" if there exist two different subsequences for which f(a)=f(b)f(a) = f(b), and "No" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

对于每组输入,如果存在两个不同的子序列使得 f(a)=f(b)f(a) = f(b),则输出“Yes”;否则输出“No”。

你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串“yEs”、“yes”、“Yes”和“YES”均会被识别为肯定回答。

输入输出样例

  • 输入#1

    5
    3
    2 1 5
    2 2 4
    2 2 3
    2
    2 1 2
    1 2
    4
    3 1 2 4
    2 2 4
    4 1 2 5 6
    2 2 5
    5
    3 3 1 2
    3 2 5 3
    5 7 2 3 1 4
    5 1 2 6 3 5
    3 2 6 3
    2
    1 1
    1 2

    输出#1

    No
    Yes
    Yes
    Yes
    No

说明/提示

It can be proven that in the first test case there are no two different subsequences aa and bb for which f(a)=f(b)f(a) = f(b).

In the second test case, one of the possible answers are following subsequences: the subsequence aa formed by the element at position 11, and the subsequence bb formed by the elements at positions 11 and 22.

In the third test case, one of the possible answers are following subsequences: the subsequence aa formed by elements at positions 11, 22, 33 and 44, and the subsequence bb formed by elements at positions 22, 33 and 44.

可以证明,在第一个测试用例中,不存在两个不同的子序列 aa 和 bb,使得 f(a)=f(b)f(a) = f(b)。

在第二个测试用例中,一组可能的答案如下:子序列 aa 由位置 11 处的元素构成,子序列 bb 由位置 11 和 22 处的元素构成。

在第三个测试用例中,一组可能的答案如下:子序列 aa 由位置 11、22、33 和 44 处的元素构成,子序列 bb 由位置 22、33 和 44 处的元素构成。

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

首页