#P2184. 贪婪大陆

贪婪大陆

Description

Xiao FF’s last line of defense is a trench of length nn. Xiao FF has infinitely many types of mines, and each time an SCV can lay mines of a single type on the interval [L,R][L, R], with this type being different from any type used before. Since the situation is urgent, at some moments Xiao FF may ask how many different types of mines are currently in the interval [L,R][L', R'], and he wants you to answer as quickly as possible.

Input Format

The first line contains two integers nn and mm, where nn is the length of the defense line and mm is the total number of SCV laying operations and Xiao FF’s queries.

Each of the next mm lines contains three integers q,l,rq, l, r:

  • If q=1q = 1, the SCV lays mines of a single, previously unused type on the interval [l,r][l, r].
  • If q=2q = 2, Xiao FF asks how many different types of mines are currently in the interval [l,r][l, r].

Output Format

For each of Xiao FF’s queries, output one answer (one per line), which is the current number of mine types in the specified interval.

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

1
2

Hint

Constraints

  • For 30%30\% of the testdata, 0n,m10000 \le n, m \le 1000.
  • For 100%100\% of the testdata, 0n,m1050 \le n, m \le 10^5.

Translated by ChatGPT 5