atcoder#ARC089C. [ARC089E] GraphXY
[ARC089E] GraphXY
Score : points
Problem Statement
AtCoDeer the deer wants a directed graph that satisfies the following conditions:
- The number of vertices, , is at most .
- There must not be self-loops or multiple edges.
- The vertices are numbered from through .
- Each edge has either an integer weight between and (inclusive), or a label
X
orY
. - For every pair of two integers such that , ,
the shortest distance from Vertex to Vertex in the graph where the edges labeled
X
have the weight and the edges labeledY
have the weight , is .
Construct such a graph (and a pair of and ) for him, or report that it does not exist. Refer to Output section for output format.
Constraints
- ( , )
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
If no graph satisfies the condition, print Impossible
.
If there exists a graph that satisfies the condition, print Possible
in the first line.
Then, in the subsequent lines, print the constructed graph in the following format:
:
Here, is the number of the edges, and , , represent edges as follows: there is an edge from Vertex to Vertex whose weight or label is .
Also refer to Sample Outputs.
2 3
1 2 2
1 2 3
Possible
3 4
1 2 X
2 3 1
3 2 Y
1 3 Y
1 3
1 3
100 50 1
Impossible