
time limit per test1 secondmemory limit per test256 megabytesYoure given an array b of length n. Lets define another array a, also of length n, for which ai2bi (1≤i≤n).Valerii says that every two non-intersecting subarrays of a have different sums of elements. You want to determine if he is wrong. More formally, you need to determine if there exist four integers l1,r1,l2,r2 that satisfy the following conditions:1≤l1≤r1l2≤r2≤n;al1al11…ar1−1ar1al2al21…ar2−1ar2.If such four integers exist, you will prove Valerii wrong. Do they exist?An array c is a subarray of an array d if c can be obtained from d by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.InputEach test contains multiple test cases. The first line contains the number of test cases t (1≤t≤100). Description of the test cases follows.The first line of every test case contains a single integer n (2≤n≤1000).The second line of every test case contains n integers b1,b2,…,bn (0≤bi≤109).OutputFor every test case, if there exist two non-intersecting subarrays in a that have the same sum, output YES on a separate line. Otherwise, output NO on a separate line.Also, note that each letter can be in any case.ExampleInputCopy2 6 4 3 0 1 2 0 2 2 5OutputCopyYES NONoteIn the first case, a[16,8,1,2,4,1]. Choosing l11, r11, l22 and r26 works because 16(81241).In the second case, you can verify that there is no way to select to such subarrays.解题说明此题是一道模拟题找规律能发现如果 b中有两个相等的值那么 aiaj。取子数组 [i,i]和 [j,j]两个单元素子数组它们不相交且和都等于 aiaj相等。因此只要 bb 中有重复元素答案就是 YES。可以用set集合来判断。#include iostream #includevector #includealgorithm #includeset using namespace std; int main() { int t; cin t; while (t--) { setint s; int n, x; cin n; for (int i 0; i n; i) { cin x; s.insert(x); } if (s.size() n) { cout NO\n; } else { cout YES\n; } } return 0; }