|
||||||||||
The Mine of AbyssTime Limit: 10000/10000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 379 Accepted Submission(s): 147 Problem Description Recently, a huge mine with $n$ crystals under deep ground has been detected in Byteland. The crystals are labeled by $1,2,\dots,n$. The weight of each crystal is not confirmed, but a range can be estimated. Specifically, the weight of the $i$-th crystal is an integer within the range $[a_i,b_i]$. You are the analyzer of this mine. You will be given $q$ operations, each operation is one of the following: - ''$\texttt{1 k a b}$'' ($1 \leq k \leq n$, $1\leq a\leq b\leq 10^9$): The $k$-th crystal is re-scanned. The new report shows its weight is an integer within the range $[a,b]$. The previous range is useless now. - ''$\texttt{2 l r}$'' ($1\leq l\leq r\leq n$): Assume some (maybe none or maybe all) crystals indexed in $[l,r]$ are unearthed, let's measure their total weight, how many possible total weights may we get? Input The first line contains a single integer $T$ ($1 \leq T \leq 5$), the number of test cases. For each test case: The first line contains two integers $n$ and $q$ ($1 \leq n,q \leq 50\,000$), denoting the number of crystals and the number of operations. In the next $n$ lines, the $i$-th line contains two integers $a_i$ and $b_i$ ($1\leq a_i,b_i\leq 10^9$), denoting the weight range of the $i$-th crystal. Each of the next $q$ lines describes an operation in formats described in the statement above. It is guaranteed that all the values of $a_i,b_i,a,b$ are chosen uniformly at random from integers in their corresponding ranges. The randomness condition does not apply to the sample test case, but your solution must pass the sample as well. Output For each query, print a single line containing an integer, denoting the number of possible total weights. Sample Input
Sample Output
Hint In the first query, the total weight can be $0$, $2$ or $3$. In the second query, the total weight can be $0$, $1$, $2$, $3$ or $4$. Source | ||||||||||
|