CF1896D.Ones and Twos
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a 1 -indexed array a of length n where each element is 1 or 2 .
Process q queries of the following two types:
- "1 s": check if there exists a subarray † of a whose sum equals to s .
- "2 i v": change ai to v .
† An array b is a subarray of an array a if b can be obtained from a 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 t ( 1≤t≤104 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers n and q ( 1≤n,q≤105 ) — the length of array a and the number of queries.
The second line of each test case contains n integers a1,a2,…,an ( ai is 1 or 2 ) — the elements of array a .
Each of the following q lines of each test case contains some integers. The first integer op is either 1 or 2 .
- If op is 1 , it is followed by one integer s ( 1≤s≤2n ).
- If op is 2 , it is followed by two integers i and v ( 1≤i≤n , v is 1 or 2 ).
It is guaranteed that the sum of n and the sum of q over all test cases both do not exceed 105 .
输出格式
For each query with op=1 , output "YES" in one line if there exists a subarray of a whose sum is equals to s , 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=5 .
- The answer for the second query is "YES" because a1+a2+a3+a4=2+1+2+1=6 .
- The answer for the third query is "NO" because we cannot find any subarray of a whose sum is 7 .
- After the fourth query, the array a becomes [2,1,2,2,2] .
- The answer for the fifth query is "YES" because a2+a3+a4+a5=1+2+2+2=7 .