benchmarks.wiki / Public workspace
Humanity's Last Code Exam / 2014_K / Surveillance
Problem
Answer published by the source. Consult the official source to check your work against its answer.
question title
Surveillance
question content
# Problem Description
The International Corporation for Protection and Control (ICPC) develops efficient technology for protection and control. Naturally, they are keen to have their own headquarters protected and controlled. Viewed from above, the headquarters building has the shape of a convex polygon. There are several suitable places around it where cameras can be installed to monitor the building. Each camera covers a certain range of the polygon sides (building walls), depending on its position. ICPC wants to minimize the number of cameras needed to cover the whole building.
## Input
The input consists of a single test case. Its first line contains two integers and ( and ), where is the number of walls and is the number of possible places for installing cameras. Each of the remaining lines contains two integers and (). These integers specify which walls a camera at the -th place would cover. If then the camera covers each wall such that . If then the camera covers each wall such that or .
## Output
Display the minimal number of cameras that suffice to cover each wall of the building. The ranges covered by two cameras may overlap. If the building cannot be covered, display `impossible` instead.
## Sample Input and Output
### Sample Input 1
Plain-text mathematical notation (without MathML)
# Problem Description The International Corporation for Protection and Control (ICPC) develops efficient technology for protection and control. Naturally, they are keen to have their own headquarters protected and controlled. Viewed from above, the headquarters building has the shape of a convex polygon. There are several suitable places around it where cameras can be installed to monitor the building. Each camera covers a certain range of the polygon sides (building walls), depending on its position. ICPC wants to minimize the number of cameras needed to cover the whole building. ## Input The input consists of a single test case. Its first line contains two integers n and k (3≤n≤10⁶ and 1≤k≤10⁶), where n is the number of walls and k is the number of possible places for installing cameras. Each of the remaining k lines contains two integers a_(i) and b_(i) (1≤a_(i),b_(i)≤n). These integers specify which walls a camera at the i-th place would cover. If a_(i)≤b_(i) then the camera covers each wall j such that a_(i)≤j≤b_(i). If a_(i)>b_(i) then the camera covers each wall j such that a_(i)≤j≤n or 1≤j≤b_(i). ## Output Display the minimal number of cameras that suffice to cover each wall of the building. The ranges covered by two cameras may overlap. If the building cannot be covered, display `impossible` instead. ## Sample Input and Output ### Sample Input 1
Original LaTeX notation
# Problem Description The International Corporation for Protection and Control (ICPC) develops efficient technology for protection and control. Naturally, they are keen to have their own headquarters protected and controlled. Viewed from above, the headquarters building has the shape of a convex polygon. There are several suitable places around it where cameras can be installed to monitor the building. Each camera covers a certain range of the polygon sides (building walls), depending on its position. ICPC wants to minimize the number of cameras needed to cover the whole building. ## Input The input consists of a single test case. Its first line contains two integers \( n \) and \( k \) (\(3 \leq n \leq 10^6\) and \(1 \leq k \leq 10^6\)), where \( n \) is the number of walls and \( k \) is the number of possible places for installing cameras. Each of the remaining \( k \) lines contains two integers \( a_i \) and \( b_i \) (\(1 \leq a_i, b_i \leq n\)). These integers specify which walls a camera at the \( i \)-th place would cover. If \( a_i \leq b_i \) then the camera covers each wall \( j \) such that \( a_i \leq j \leq b_i \). If \( a_i > b_i \) then the camera covers each wall \( j \) such that \( a_i \leq j \leq n \) or \( 1 \leq j \leq b_i \). ## Output Display the minimal number of cameras that suffice to cover each wall of the building. The ranges covered by two cameras may overlap. If the building cannot be covered, display `impossible` instead. ## Sample Input and Output ### Sample Input 1
Code
100 7
1 50
50 70
70 90
90 40
20 60
60 80
80 20
### Sample Output 1
Code
3
### Sample Input 2
Code
8 2
8 3
5 7
### Sample Output 2
Code
impossible
### Sample Input 3
Code
8 2
8 4
5 7
### Sample Output 3
Code
2
platform
atcoder
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import