CF1923C.Find B

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

An array aa of length mm is considered good if there exists an integer array bb of length mm such that the following conditions hold:

  1. ∑i=1mai=∑i=1mbi\sum\limits_{i=1}^{m} a_i = \sum\limits_{i=1}^{m} b_i;
  2. ai≠bia_i \neq b_i for every index ii from 11 to mm;
  3. bi>0b_i \gt 0 for every index ii from 11 to mm.

You are given an array cc of length nn. Each element of this array is greater than 00.

You have to answer qq queries. During the ii-th query, you have to determine whether the subarray cli,cli+1,…,cric_{l_{i}}, c_{l_{i}+1}, \dots, c_{r_{i}} is good.

长度为 mm 的数组 aa 被称为好数组,当且仅当存在一个长度为 mm 的整数数组 bb,满足以下条件:

  1. ∑i=1mai=∑i=1mbi\sum\limits_{i=1}^{m} a_i = \sum\limits_{i=1}^{m} b_i;
  2. 对每个下标 ii(1≤i≤m1 \le i \le m),均有 ai≠bia_i \neq b_i;
  3. 对每个下标 ii(1≤i≤m1 \le i \le m),均有 bi>0b_i \gt 0。

给定一个长度为 nn 的数组 cc,其中每个元素均大于 00。

你需要回答 qq 个查询。在第 ii 个查询中,你需要判断子数组 cli,cli+1,…,cric_{l_{i}}, c_{l_{i}+1}, \dots, c_{r_{i}} 是否为好数组。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers nn and qq (1≤n,q≤3⋅1051 \le n, q \le 3 \cdot 10^5) — the length of the array cc and the number of queries.

The second line of each test case contains nn integers c1,c2,…,cnc_1, c_2, \dots, c_n (1≤ci≤1091 \le c_i \le 10^9).

Then qq lines follow. The ii-th of them contains two integers lil_i and rir_i (1≤li≤ri≤n1 \le l_i \le r_i \le n) — the borders of the ii-th subarray.

Additional constraints on the input: the sum of nn over all test cases does not exceed 3⋅1053 \cdot 10^5; the sum of qq over all test cases does not exceed 3⋅1053 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)——测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 qq(1≤n,q≤3⋅1051 \le n, q \le 3 \cdot 10^5)——数组 cc 的长度和查询次数。

每个测试用例的第二行包含 nn 个整数 c1,c2,…,cnc_1, c_2, \dots, c_n(1≤ci≤1091 \le c_i \le 10^9)。

接下来是 qq 行,其中第 ii 行包含两个整数 lil_i 和 rir_i(1≤li≤ri≤n1 \le l_i \le r_i \le n)——第 ii 个子数组的左右边界。

输入的额外约束:所有测试用例的 nn 之和不超过 3⋅1053 \cdot 10^5;所有测试用例的 qq 之和不超过 3⋅1053 \cdot 10^5。

输出格式

For each query, print YES if the subarray is good. Otherwise, print NO.

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

对于每个查询,如果子数组是“好”的,则输出 YES;否则输出 NO。

答案的每个字母可以是任意大小写(大写或小写)。例如,字符串 yEs、yes、Yes 和 YES 均会被识别为肯定回答。

输入输出样例

  • 输入#1

    1
    5 4
    1 2 1 4 5
    1 5
    4 4
    3 4
    1 3

    输出#1

    YES
    NO
    YES
    NO

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

首页