#P4155. [SCOI2015] 国旗计划
[SCOI2015] 国旗计划
Description
Country A is carrying out a great plan — the National Flag Plan. In this plan, border guards will run a full loop along the border line in relay while holding the national flag. This requires multiple border guards working together in relay. The National Security Agency has selected outstanding border guards as candidates.
Country A is vast, and there are border posts on the border line, numbered to clockwise. Each border guard is based at two border posts and is skilled at long-distance running between these two posts. We call the path between these two posts the guard’s running interval. The guards are carefully selected and in excellent physical condition, so no guard’s running interval is contained within another guard’s running interval.
The director of the National Security Agency wants to know the minimum number of border guards whose running intervals can cover the entire border line to successfully complete the National Flag Plan. Moreover, for each border guard, under the condition that he must participate, the director also wants to know the minimum number of border guards required to cover the entire border line.
Input Format
The first line contains two positive integers , the number of border guards and the number of border posts.
Then follow lines, each containing two positive integers. On the -th line, the two integers denote the indices of the two border posts where guard is based. The running interval of guard is from post to post in the clockwise direction. It is guaranteed that the entire border line can be covered.
Output Format
Output a single line containing positive integers. The -th integer denotes, under the condition that guard must participate, the minimum number of border guards required to successfully complete the National Flag Plan.
4 8
2 5
4 7
6 1
7 3
3 3 4 3
Hint
Constraints: $N \leq 2 \times 10^5, M < 10^9, 1 \leq C_i, D_i \leq M$.
Translated by ChatGPT 5
京公网安备 11011102002149号