#P14447. [ICPC 2025 Xi'an R] Azalea Garden

[ICPC 2025 Xi'an R] Azalea Garden

题目描述

In a serene garden of azaleas, nn dangerous creatures have appeared. Each creature possesses an attack power\textit{attack power} and a defense power\textit{defense power}. Initially, the ii-th creature (1in1 \leq i \leq n) has an attack power of aia_i and a defense power of bib_i.

You, the guardian of the azalea garden, can mentally imagine a war\textit{war} between them. A war\textit{war} consists of several (possibly, 00) battles\textit{battles}. In each imagined battle\textit{battle}, you choose two living creatures ii and jj (1i,jn1 \leq i, j \leq n, iji \neq j), and:

  • If the attack power of creature ii is greater than or equal to the defense power of creature jj (i.e. aibja_i \geq b_j), then ii can defeat jj in the battle, and jj is considered eliminated.
  • Otherwise, nothing happens.

Note that the wars\textit{wars} are imaginary; that is, a creature eliminated cannot be used for future battles\textit{battles} in the same war\textit{war}, but it regains its vigor at the beginning of the next war\textit{war}, and thus can participate in future battles\textit{battles} of consequent wars\textit{wars}.

The creatures are volatile and undergo mutations over time. You are given qq mutations. After each of the mutations, the attributes of a creature change. Specifically, in the ii-th mutation, the viv_i-th creature has its attack power updated to xix_i and its defense power updated to yiy_i. Note that the mutations are persistent; After the ii-th mutation, the impacts of the first i1i-1 mutations are accumulated.

Since each remaining creature poses an ongoing threat to the flowers, you want to find the minimum possible number of creatures that remain after an optimal sequence of an imagined war\textit{war}. You need to answer the question for all states before all mutations and after each mutation.

输入格式

The first line of the input contains two integers nn and qq (1n41051 \leq n \leq 4 \cdot 10^5, 0q41050 \leq q \leq 4 \cdot 10^5), where nn is the number of creatures and qq is the number of mutations.

The next nn lines of the input describe all the creatures. The ii-th line of these contains two integers aia_i and bib_i (1ai,bi1091 \leq a_i, b_i \leq 10^9), where aia_i is the attack power and bib_i is the defense power of the ii-th creature.

The next qq lines of the input describe all the mutations. The ii-th line of these contains three integers viv_i, xix_i, and yiy_i (1vin1 \leq v_i \leq n, 1xi,yi1091 \leq x_i, y_i \leq 10^9), where xix_i is the new attack power of creature viv_i and yiy_i is the new defense power of creature viv_i.

输出格式

Output q+1q + 1 lines, each containing a single integer, which are the answers before any mutations and after each mutation in sequence.

3 1
1 1
2 2
3 3
2 2 4
1
2

提示

In the example, before the mutations begin, the third creature can defeat the first and second creatures. Clearly, this is the optimal sequence of imagined battles, so the answer is 11.

After the first mutation ends, the attack power of the second creature becomes 22, and its defense power becomes 44. Now the third creature can only defeat the first creature, leaving 22 creatures remaining. It can be proved that no better solution exists, so the answer is 22.