| Codeforces Round 1130 (Div. 2) |
|---|
| Finished |
There are $$$n$$$ positions numbered from $$$1$$$ to $$$n$$$.
For every interval $$$[l,r]$$$, where $$$1 \le l \le r \le n$$$, there is a value associated with this interval. Values can be obtained in the following ways:
You may use the second operation any number of times. Values cannot be split: knowing the value for $$$[l,r]$$$ does not give you the values for its subintervals. There are no other ways to obtain values.
At any moment, there are $$$m$$$ required intervals. Your task is to determine the minimum number of direct queries needed to obtain the values for all required intervals.
After the initial configuration, $$$q$$$ modifications are performed. Each modification replaces one required interval with a new interval. You must output the answer for the initial configuration and after each modification.
Each configuration is considered independently. That is, for every output value, you need the minimum number of direct queries needed starting with no values already obtained.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$q$$$ ($$$1 \le n,m,q \le 2\cdot 10^5$$$) — the number of positions, the number of required intervals, and the number of modifications.
The next $$$m$$$ lines contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le n$$$). They describe the initial required intervals.
The next $$$q$$$ lines contain three integers $$$p$$$, $$$l$$$, and $$$r$$$ ($$$1 \le p \le m$$$, $$$1 \le l \le r \le n$$$). The required interval with index $$$p$$$ is replaced by $$$[l,r]$$$.
It is guaranteed that the sums of $$$n$$$, $$$m$$$, and $$$q$$$ over all test cases do not exceed $$$2\cdot 10^5$$$ each.
For each test case, print $$$q+1$$$ integers, each on a separate line.
The first integer must be the minimum number of direct queries needed for the initial configuration. Then, after each modification, print the minimum number of direct queries needed for the current configuration.
35 3 31 23 52 43 1 51 2 22 4 53 2 21 31 32 1 11 2 315 8 815 1513 1410 108 128 1515 1515 1514 141 3 38 10 124 12 146 13 156 7 118 10 123 1 35 11 12
3233122566778888
In the first test case, initially at least $$$3$$$ direct queries are needed, so the answer is $$$3$$$.
After the first modification, the required intervals are $$$[1,2]$$$, $$$[3,5]$$$, and $$$[1,5]$$$. We can query $$$[1,2]$$$ and $$$[3,5]$$$ directly, and combine them to obtain $$$[1,5]$$$. Therefore, only $$$2$$$ direct queries are needed.
After the second modification, the required intervals are $$$[2,2]$$$, $$$[3,5]$$$, and $$$[1,5]$$$. At least $$$3$$$ direct queries are needed, so the answer is $$$3$$$.
After the third modification, the required intervals are $$$[2,2]$$$, $$$[4,5]$$$, and $$$[1,5]$$$. Again, at least $$$3$$$ direct queries are needed, so the answer is $$$3$$$.
In the second test case, the two initial required intervals are identical, so one direct query is enough and the answer is $$$1$$$.
After each modification, at least $$$2$$$ direct queries are needed, so the answers are both $$$2$$$.
| Name |
|---|


