CF1896D.Ones and Twos

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given a 11 -indexed array aa of length nn where each element is 11 or 22 .

Process qq queries of the following two types:

  • "1 s": check if there exists a subarray ^{\dagger} of aa whose sum equals to ss .
  • "2 i v": change aia_i to vv .

^{\dagger} An array bb is a subarray of an array aa if bb can be obtained from aa by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.

输入格式

Each test contains multiple test cases. The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and qq ( 1n,q1051\le n,q\le 10^5 ) — the length of array aa and the number of queries.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n ( aia_i is 11 or 22 ) — the elements of array aa .

Each of the following qq lines of each test case contains some integers. The first integer op\mathrm{op} is either 11 or 22 .

  • If op\mathrm{op} is 11 , it is followed by one integer ss ( 1s2n1 \leq s \leq 2n ).
  • If op\mathrm{op} is 22 , it is followed by two integers ii and vv ( 1in1 \leq i \leq n , vv is 11 or 22 ).

It is guaranteed that the sum of nn and the sum of qq over all test cases both do not exceed 10510^5 .

输出格式

For each query with op=1\mathrm{op}=1 , output "YES" in one line if there exists a subarray of aa whose sum is equals to ss , otherwise output "NO".

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

    2
    5 5
    2 1 2 1 2
    1 5
    1 6
    1 7
    2 4 2
    1 7
    3 2
    2 2 2
    1 6
    1 5

    输出#1

    YES
    YES
    NO
    YES
    YES
    NO

说明/提示

Consider the first example:

  • The answer for the first query is "YES" because a1+a2+a3=2+1+2=5a_1+a_2+a_3=2+1+2=5 .
  • The answer for the second query is "YES" because a1+a2+a3+a4=2+1+2+1=6a_1+a_2+a_3+a_4=2+1+2+1=6 .
  • The answer for the third query is "NO" because we cannot find any subarray of aa whose sum is 77 .
  • After the fourth query, the array aa becomes [2,1,2,2,2][2,1,2,2,2] .
  • The answer for the fifth query is "YES" because a2+a3+a4+a5=1+2+2+2=7a_2+a_3+a_4+a_5=1+2+2+2=7 .
首页