TopCoder

User's AC Ratio

90.6% (58/64)

Submission's AC Ratio

38.3% (123/321)

Tags

Description

有一個序列 $A$ 長度為 $N(N \leq 3 \times 10^ 5)$
剛開始 $A_0 = 0, A_1 = 0,\ldots,A_{N-1} = 0$
接下來有 $M(M \leq 3 \times 10^ 5)$ 個操作
每個操作之間間隔一單位時間
時間由第一個操作算起

1 l r x 代表將 A[l, r] += x $(0 \leq l \leq r < n)$, $|x| = 1$
2 x 代表詢問從開始到現在,有幾單位時間 $A_x$ 為 $0$, $(0 \leq x < n)$

保證在操作過程中,所有 $A$ 的元素皆不小於 $0$

Input Format

第一行有兩個正整數 $N, M$
接下來有 $M$ 行,
每行皆有一筆操作,格式如上

Output Format

對於每一筆操作請輸出一行整數代表答案

Sample Input 1

3 6
1 0 1 1
1 1 2 1
1 0 2 -1
2 0
2 1
2 2

Sample Output 1

1
0
4

Hints

不要中毒 ><

Problem Source

by kevin_zhang

Subtasks

No. Testdata Range Constraints Score
1 0~9 $N, M \leq 5000$ 15
2 0~29 $N, M \leq 30000$ 20
3 0~44 no additional limits 65

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1 2 3
1 1000 65536 65536 1 2 3
2 1000 65536 65536 1 2 3
3 1000 65536 65536 1 2 3
4 1000 65536 65536 1 2 3
5 1000 65536 65536 1 2 3
6 1000 65536 65536 1 2 3
7 1000 65536 65536 1 2 3
8 1000 65536 65536 1 2 3
9 1000 65536 65536 1 2 3
10 1000 65536 65536 2 3
11 1000 65536 65536 2 3
12 1000 65536 65536 2 3
13 1000 65536 65536 2 3
14 1000 65536 65536 2 3
15 1000 65536 65536 2 3
16 1000 65536 65536 2 3
17 1000 65536 65536 2 3
18 1000 65536 65536 2 3
19 1000 65536 65536 2 3
20 1000 65536 65536 2 3
21 1000 65536 65536 2 3
22 1000 65536 65536 2 3
23 1000 65536 65536 2 3
24 1000 65536 65536 2 3
25 1000 65536 65536 2 3
26 1000 65536 65536 2 3
27 1000 65536 65536 2 3
28 1000 65536 65536 2 3
29 1000 65536 65536 2 3
30 1000 65536 65536 3
31 1000 65536 65536 3
32 1000 65536 65536 3
33 1000 65536 65536 3
34 1000 65536 65536 3
35 1000 65536 65536 3
36 1000 65536 65536 3
37 1000 65536 65536 3
38 1000 65536 65536 3
39 1000 65536 65536 3
40 1000 65536 65536 3
41 1000 65536 65536 3
42 1000 65536 65536 3
43 1000 65536 65536 3
44 1000 65536 65536 3