Logo
(追記) (追記ここまで)

34914번 - Busy Beaver's Dam Logs 서브태스크점수다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB104450.000%

문제

Busy Beaver has arranged $N$ logs in a line to form the base of his dam. Each log has an integer quality value between $-2$ and 2ドル$. From time to time, some logs are replaced. He occasionally wants to know if there is a contiguous segment of logs whose total quality equals a given nonzero number $X,ドル and may also want to know the segment. Help Busy Beaver process all updates and queries efficiently.

입력

The first line of input contains an integer $T$ (1ドル \le T \le 10^4$) --- the number of testcases.

The first line of each test case contains two integers $N$ and $Q$ (1ドル \le N,Q \le 2\cdot 10^5$) --- the size of the array and the number of queries, respectively.

The second line of each test case contains $N$ integers $a_1, a_2, \dots, a_N$ ($-2 \le a_i \le 2$) --- the qualities of the logs.

The next $Q$ lines of each test case are of two forms:

  • 1ドル\ i\ x$ (1ドル \le i \le N,ドル $-2\le x\le 2$) --- set the quality of the $i$-th log to $x$.
  • 2ドル\ X$ ($-2N\le X \le 2N,ドル $X\ne 0$) --- find a contiguous segment of logs with total quality $X$.

There is at least one query of the second type.

The sum of $N$ over all test cases does not exceed 2ドル\cdot 10^5$.

The sum of $Q$ over all test cases does not exceed 2ドル\cdot 10^5$.

출력

For each query of the second type, if a valid contiguous segment exists, print YES on the first line, followed by the left and right indices of that segment $l$ and $r$ on the next line (1ドル \le l \le r \le N$). If no such segment exists, print NO on a single line.

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.

제한

서브태스크

You can receive 50ドル\%$ of the points for each subtask if the YES/NO answers are correct, but the indices are incorrect. To obtain these partial points, you must still output integers $l$ and $r$ between 1ドル$ and $N$ after all YES answers.

번호배점제한
110

The sum of $N$ over all test cases is at most 10ドル^3,ドル and the sum of $Q$ over all test cases is at most 10ドル^3$.

220

$-1\le a_i\le 1$ for all $i,ドル and for any query of the first type, $-1\le x\le 1$.

330

0ドル\le a_i\le 2$ for all $i,ドル and for any query of the first type, 0ドル\le x\le 2$.

440

No additional constraints.

예제 입력 1

4
5 5
-1 2 0 -2 1
1 2 1
2 1
1 4 2
2 3
2 -2
4 3
-1 -1 -1 -1
1 4 1
2 -1
2 -4
6 6
1 -1 1 -1 1 -1
1 3 0
2 1
2 -2
2 3
1 3 2
2 1
6 3
0 0 0 0 0 0
2 2
1 1 1
2 1

예제 출력 1

YES
2 2
YES
3 5
NO
YES
2 2
NO
YES
1 1
YES
2 4
NO
YES
1 1
NO
YES
1 1

노트

For the first test case:

  • The initial array is $[-1, 2, 0, -2, 1]$.
  • After the first query 1ドル\ 2\ 1,ドル the array becomes $[-1, 1, 0, -2, 1]$.
  • The second query 2ドル\ 1$ asks for a contiguous segment summing to 1ドル,ドル which can be achieved by $[1]$ (element 2ドル$).
  • After the third query 1ドル\ 4\ 2,ドル the array becomes $[-1, 1, 0, 2, 1]$.
  • The fourth query 2ドル\ 3$ asks for a contiguous segment summing to 3ドル,ドル which can be achieved by $[1,0,2]$ (elements 2ドル$--4ドル$).
  • The fifth query 2ドル\ {-2}$ asks for a contiguous segment summing to $-2$. It can be checked that no such subarray exists.

For the second test case:

  • The initial array is $[-1, -1, -1, -1]$.
  • After the first query 1ドル\ 4\ 1,ドル the array becomes $[-1, -1, -1, 1]$.
  • The second query 2ドル\ {-1}$ asks for a contiguous segment summing to $-1,ドル which can be achieved by $[-1]$ (any of the first three elements).
  • The third query 2ドル\ {-4}$ asks for a contiguous segment summing to $-4$. It can be checked that no such subarray exists.

출처

University > MIT > M(IT)^2 > M(IT)^2 Winter 2025-26 Tournament > Advanced Team Round 7번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /