CF1775B.Gardener and the Array
普及/提高-
通过率:0%
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.
输入格式
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 .
输出格式
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.
输入输出样例
输入#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 .