A13958 | Valerii Against Everyone
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You're given an array $b$ of length $n$ . Let's define another array $a$ , also of length $n$ , for which $a_i = 2^{b_i}$ ( $1 \leq i \leq 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 $l_1,r_1,l_2,r_2$ that satisfy the following conditions:
1. $1 \leq l_1 \leq r_1 \lt l_2 \leq r_2 \leq n$ ;
2. $a_{l_1}+a_{l_1+1}+\ldots+a_{r_1-1}+a_{r_1} = a_{l_2}+a_{l_2+1}+\ldots+a_{r_2-1}+a_{r_2}$ .
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.
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 $l_1,r_1,l_2,r_2$ that satisfy the following conditions:
1. $1 \leq l_1 \leq r_1 \lt l_2 \leq r_2 \leq n$ ;
2. $a_{l_1}+a_{l_1+1}+\ldots+a_{r_1-1}+a_{r_1} = a_{l_2}+a_{l_2+1}+\ldots+a_{r_2-1}+a_{r_2}$ .
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.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 100$ ). Description of the test cases follows.
The first line of every test case contains a single integer $n$ ( $2 \le n \le 1000$ ).
The second line of every test case contains $n$ integers $b_1,b_2,\ldots,b_n$ ( $0 \le b_i \le 10^9$ ).
The first line of every test case contains a single integer $n$ ( $2 \le n \le 1000$ ).
The second line of every test case contains $n$ integers $b_1,b_2,\ldots,b_n$ ( $0 \le b_i \le 10^9$ ).
输出格式
For 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.
Also, note that each letter can be in any case.
输入输出样例
输入 #1
2 6 4 3 0 1 2 0 2 2 5
输出 #1
YES NO
In the first case, $a = [16,8,1,2,4,1]$ . Choosing $l_1 = 1$ , $r_1 = 1$ , $l_2 = 2$ and $r_2 = 6$ works because $16 = (8+1+2+4+1)$ .
In the second case, you can verify that there is no way to select to such subarrays.
In the second case, you can verify that there is no way to select to such subarrays.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted