| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 6 초 | 2048 MB | 7 | 3 | 3 | 50.000% |
Busy Beaver is an avid fan of Sheet Music Boss and dreams of playing long, intricate pieces on his piano. However, with only a measly 10ドル$ fingers, there's not much he can do. Fortunately, his friend Ditto can grow an arbitrary number of fingers on their hand, letting them play any piece imaginable.
Ditto is trying to play a song consisting of $N$ notes, numbered 1ドル$ to $N$. To play the $i$-th note, Ditto must press key $k_i$ at time $a_i$ and let go at time $b_i$. It is guaranteed that no two notes with the same key are played at the same time. In other words, for all pairs of notes $(i,j)$ where $k_i=k_j,ドル either $b_i\le a_j$ or $b_j\le a_i$.
Ditto plans to use a single hand with $F$ fingers, numbered left to right from 1ドル$ to $F,ドル to play the song. They want to assign the finger $f_i$ to the $i$-th note. Ditto can play the song if they can assign a finger to each note to satisfy the following criteria:
Ditto is allowed to delete up to $M$ notes from the song, where $M$ is $\mathbf{0}$ or $\mathbf{1}$. Find the minimum number of fingers they need on their hand in order to play the rest of the song. In other words, find the smallest $F$ where there exists a finger assignment $f$ that satisfies the above criteria.
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 two integers $N$ and $M$ (1ドル\le N\le 2\cdot 10^5,ドル $M=0$ or 1ドル$).
The $i$-th of the next $N$ lines contains three integers $k_i,ドル $a_i,ドル and $b_i$ (1ドル\le k_i \le 10^9,ドル 1ドル\le a_i < b_i \le 10^9$) --- meaning that the $i$-th note uses key $k_i$ from time $a_i$ to time $b_i$.
It is guaranteed that no two notes with the same key are played at the same time and the sum of $N$ over all test cases does not exceed 2ドル\cdot 10^5$.
For each test case, print the minimum number of fingers Ditto needs on their hand so that after at most $M$ note deletions, there exists a satisfactory finger assignment.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | The sum of $N$ over all test cases does not exceed 10ドル^3$ and $M=0$. |
| 2 | 20 | $M=0$. |
| 3 | 70 | No additional constraints. |
5 5 0 3 3 6 5 2 5 6 5 6 1 1 4 1 5 7 5 1 2 1 6 10 1 6 4 5 9 8 5 9 6 8 10 4 1 1 1 2 2 1 2 1 3 4 2 3 4 1 0 6 2 5 1 1 6 2 5
3 3 2 1 0
The notes for the first test case are shown below. The x-axis is the key pressed, and the y-axis is the time interval the note is pressed. The minimum number of fingers required is 3ドル$ --- each note is labeled with a finger to achieve this.
The notes for the second test case are shown below. Deleting either the yellow or blue note would make 3ドル$ fingers sufficient, and this is optimal.