atcoder#AGC043E. [AGC043E] Topology
[AGC043E] Topology
Score : points
Problem Statement
Given are a positive integer and a sequence of length consisting of s and s: . Determine whether there exists a closed curve that satisfies the condition below for all sets . If the answer is yes, construct one such closed curve.
- Let and be the set of points .
- If there is a way to continuously move the closed curve without touching so that every point on the closed curve has a negative -coordinate, .
- If there is no such way, .
For instruction on printing a closed curve, see Output below.
Notes
is said to be a closed curve if and only if:
- is a continuous function from to such that .
We say that a closed curve can be continuously moved without touching a set of points so that it becomes a closed curve if and only if:
- There exists a function that satisfies all of the following.- is continuous.
- .
- .
- .
- is continuous.
- .
- .
- .
Constraints
Input
Input is given from Standard Input in the following format:
Output
If there is no closed curve that satisfies the condition, print Impossible
.
If such a closed curve exists, print Possible
in the first line.
Then, print one such curve in the following format:
This represents the closed polyline that passes in this order.
Here, all of the following must be satisfied:
- , , and are integers. ()
- . ()
- .
Additionally, the length of the closed curve must satisfy .
It can be proved that, if there is a closed curve that satisfies the condition in Problem Statement, there is also a closed curve that can be expressed in this format.
1
10
Possible
4
0 0
0 1
1 1
1 0
0 0
When , we can move this curve so that every point on it has a negative -coordinate.
When , we cannot do so.
2
1000
Possible
6
1 0
2 0
2 1
1 1
0 1
0 0
1 0
The output represents the following curve:
2
1001
Impossible
1
11
Possible
0
1 1