| The Andover Computing Open (TACO) 2023 |
|---|
| Закончено |
There are $$$n$$$ people numbered from $$$1$$$ to $$$n$$$ in a social network. We have $$$m$$$ pieces of information that tell us their connections, in which the $$$i$$$-th one gives us that $$$x_i$$$ are friends with anyone with number $$$y$$$, where $$$L_i\le y\le R_i$$$. Basically, person $$$x_i$$$ is with the range of people from $$$L_i$$$ to $$$R_i$$$.
Now, Harry wants to notify them of an important message. The only way for him to do that is by sending messages to some individuals in the network. If anyone receives a message, he or she will share the message with all his or her friends. Given that friendship is mutual and all pairs of friends are included in our information, what is the minimum number of messages Harry needs to send so that everyone in the network receives the message?
The first line contains two integer $$$n,m$$$ $$$(1\le n\le 10^{12},1\le m\le 2\times 10^5)$$$.
The next $$$m$$$ line each contains three integer $$$x_i,L_i,R_i$$$ $$$(1\le x_i\le n,1\le L_i\le R_i\le n)$$$.
Output a single integer, the minimum number of messages Harry needs to send so that everyone in the network receives the message.
5 3 1 2 2 2 3 3 3 4 4
2
7 2 1 2 4 6 2 3
3
10 4 2 3 6 1 2 3 8 7 9 3 1 5
3
| Название |
|---|


