CF1775B.Gardener and the Array
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The gardener Kazimir Kazimirovich has an array of n integers c1,c2,…,cn.
He wants to check if there are two different subsequences a and b of the original array, for which f(a)=f(b), where f(x) is the bitwise OR of all of the numbers in the sequence x.
A sequence q is a subsequence of p if q can be obtained from p 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.

园丁卡西米尔·卡西米罗维奇有一个包含 n 个整数的数组 c1,c2,…,cn。
他想检查原数组中是否存在两个不同的子序列 a 和 b,使得 f(a)=f(b),其中 f(x) 表示序列 x 中所有数字的按位或结果。
若序列 q 可通过从序列 p 中删除若干(可能为零个、部分或全部)元素得到,则称 q 是 p 的一个子序列。
当且仅当两个子序列在原数组中所对应元素的下标集合不同时,才认为它们是不同的;即,在比较子序列时,不考虑元素的具体数值。

输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤105). The description of the test cases follows.
The first line of each test case contains one integer n (1≤n≤105) — the size of the array c.
The description of the array c in this problem is given implicitly to speed up input.
The (i+1)-st of the following n lines of the test case begins with an integer ki (1≤ki≤105) — the number of set bits in the number ci. Next follow ki distinct integers pi,1,pi,2,…,pi,ki (1≤pi≤2⋅105) —the numbers of bits that are set to one in number ci. In other words, ci=2pi,1+2pi,2+…+2pi,ki.
It is guaranteed that the total sum of ki in all tests does not exceed 105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤105)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤105)—— 数组 c 的大小。
本题中,数组 c 的描述以隐式方式给出,以加快输入速度。
该测试用例接下来的 n 行中,第 (i+1) 行首先是一个整数 ki(1≤ki≤105)—— 表示数字 ci 的二进制表示中为 1 的位数(即“置位比特数”)。随后是 ki 个互不相同的整数 pi,1,pi,2,…,pi,ki(1≤pi≤2⋅105)—— 表示 ci 中值为 1 的那些比特位的编号(从最低位起编号为 1)。换言之,ci=2pi,1+2pi,2+…+2pi,ki。
保证所有测试用例中 ki 的总和不超过 105。
输出格式
For each set of input, print "Yes" if there exist two different subsequences for which 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),则输出“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 a and b for which f(a)=f(b).
In the second test case, one of the possible answers are following subsequences: the subsequence a formed by the element at position 1, and the subsequence b formed by the elements at positions 1 and 2.
In the third test case, one of the possible answers are following subsequences: the subsequence a formed by elements at positions 1, 2, 3 and 4, and the subsequence b formed by elements at positions 2, 3 and 4.
可以证明,在第一个测试用例中,不存在两个不同的子序列 a 和 b,使得 f(a)=f(b)。
在第二个测试用例中,一组可能的答案如下:子序列 a 由位置 1 处的元素构成,子序列 b 由位置 1 和 2 处的元素构成。
在第三个测试用例中,一组可能的答案如下:子序列 a 由位置 1、2、3 和 4 处的元素构成,子序列 b 由位置 2、3 和 4 处的元素构成。
输入解题思路,AI测评打分。不知道怎么写?