F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

The Mine of Abyss

Time 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
1 3 5 2 3 1 1 3 4 2 1 1 2 1 2 2 1 3 1 2 1 5 2 1 3
 

Sample Output
3 5 9 13
 

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
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 16:39:58, Gzip enabled