0 Judge
Code: 0
For all real numbers $a\le b$, the closed interval $[a,b]$ refers to the set of all real numbers between $a$ and $b$, inclusive. For example, $[3,5]=\{x\in\mathbb{R}\mid 3\le x\le 5\}$.
Bob has $n$ closed intervals, denoted $[a_1,b_1]$, $[a_2,b_2]$, $\ldots$, $[a_n,b_n]$, such that for all distinct $i$, $j\in\{1,2,\ldots,n\}$,
He wants to color each of the $n$ closed intervals monochromatically such that any two distinct overlapping intervals are in different colors. Bob wonders how many colors are needed. In other words, he wants to find the minimum positive integer $k$ such that each of the $n$ closed intervals can be labelled with one of $1$, $2$, $\ldots$, $k$ in a way that any two distinct overlapping intervals are labelled differently. Please help him.
The first line contains the number $T$ of test cases. Each of the next $T$ lines specifies a test case by providing $n$, $a_1$, $b_1$, $a_2$, $b_2$, $\ldots$, $a_n$, $b_n$, in that order. Two consecutive numbers in a line are separated by one or more spaces.
You may assume:
For each test case, output the minimum positive integer $k$ such that each of $[a_1,b_1]$, $[a_2,b_2]$, $\ldots$, $[a_n,b_n]$ can be labelled with one of $1$, $2$, $\ldots$, $k$ in a way that any two distinct overlapping intervals are labelled differently.
3
4 1 2 3 5 4 8 6 7
5 2 5 1 10 3 7 4 6 8 9
4 3 7 4 5 2 9 6 8
2
4
3
對任兩個實數$a\le b$,閉區間$[a,b]$乃指介於$a$與$b$之間(包含$a$與$b$)的實數之集合。 例如,$[3,5]=\{x\in\mathbb{R}\mid 3\le x\le 5\}$。
鮑伯有$n$個閉區間,分別為$[a_1,b_1]$、$[a_2,b_2]$、$\ldots$、$[a_n,b_n]$,其中對所有相異$i$、$j\in\{1,2,\ldots,n\}$,
他想要將每個閉區間塗上一個顏色,且使任兩相異且有交集的區間被塗上相異的顏色。鮑伯想知道最少要有幾個顏色才可以做這件事。換句話說,他想找到最小的正整數$k$,使得$n$個閉區間中的都可以被賦予$1$、$2$、$\ldots$、$k$中的一個值,而使任兩相異且相交的區間被賦予的值相異。請幫他算吧。
第一行給出測資筆數$T$。接下來的$T$行中,每一行都指定一筆測資,指定的方法是依序給出$n$、$a_1$、$b_1$、$a_2$、$b_2$、$\ldots$、$a_n$、$b_n$。同一行中的連續兩數字將被一或多個空白隔開。
可假設:
對每一筆測資,輸出最小的正整數$k$,使得$[a_1,b_1]$、$[a_2,b_2]$、$\ldots$、$[a_n,b_n]$中的任何一個都可以被賦予$1$、$2$、$\ldots$、$k$中的一個值,而使任兩相異且相交的區間被賦予的值相異。