| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 (추가 시간 없음) | 1024 MB | 56 | 27 | 27 | 54.000% |
You are addicted to the latest world-simulation game: Building A Perfect City. In your current play-through, you have created a city that has an equal number of streets and intersections. All that is left is to number the houses in every street.
The city is represented by a connected graph with intersections and streets. Every street is a connection between two intersections $u$ and $v,ドル and has $h$ houses which are all on one side of the street. There is at most one street between two intersections. There are two ways to number the houses in this street: either you start with house number 1ドル$ adjacent to intersection $u$ and end with house number $h$ at intersection $v,ドル or house number 1ドル$ is adjacent to $v$ and house number $h$ is adjacent to $u$. To avoid confusion, you want to ensure that no intersection has two adjacent houses with the same number.
Find a way to number the houses in every street that satisfies this property (or report that it is impossible).
The input consists of:
It is guaranteed that every intersection is reachable from every other intersection. There is at most one street between any two intersections.
If it is impossible, output "impossible". Otherwise, output for each street (in the same order as the input) a number representing the intersection where the house numbering starts.
If there are multiple valid solutions, you may output any one of them.
3 1 2 2 2 3 9 3 1 3
1 2 3
4 1 2 2 1 3 2 2 3 2 1 4 2
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2022 H번