luogu#P7968. [COCI 2021/2022 #2] Osumnjičeni
[COCI 2021/2022 #2] Osumnjičeni
Problem Description
There are suspects. Due to uncertainty about their heights, we only know each suspect’s height range .
In each investigation, you may choose all suspects whose indices are in a range , and it is required that their height ranges do not intersect. If a suspect appears in an investigation, the witness can immediately make a correct identification.
You are given queries. Each query gives . Under the condition that the suspects’ index range is , find the minimum number of investigations needed.
Input Format
The first line contains a positive integer , the number of suspects.
The next lines each contain two positive integers , representing the height range of the -th suspect.
The next line contains a positive integer , the number of queries.
The next lines each contain two positive integers , representing one query.
Output Format
Output lines, where each line is the answer to the corresponding query.
2
1 1
1 1
3
1 1
2 2
1 2
1
1
2
3
1 1
2 2
3 3
3
1 1
2 3
1 3
1
1
1
5
1 3
3 3
4 6
2 3
1 1
3
1 4
3 5
1 5
3
1
3
Hint
[Sample 3 Explanation]
- Query : It is enough to investigate within ranges , , and , so the answer is .
- Query : Investigate only, so the answer is .
[Constraints and Notes]
This problem uses bundled subtasks.
- Subtask 1 (10 pts): , .
- Subtask 2 (10 pts): .
- Subtask 3 (20 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (50 pts): No additional restrictions.
For of the testdata, , , , .
[Hints and Explanations]
Translated from COCI 2021-2022 CONTEST #2 Task 5 Osumnjičeni.
The score of this problem follows the original COCI settings, with a full score of .
Translated by ChatGPT 5