| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 9 | 9 | 9 | 100.000% |
It is the 25th of August, 225 BCE. You are in charge of the annual road trip of the Backtracking-Averse Promenaders Club in Rome. Alas, you get homesick easily and would much rather stay at home. Therefore, your goal is to keep the road trip as short as possible. Traditionally, the road trip cannot backtrack along a road it just used -- your friends would start to complain. Specifically, if you travel directly from site $x$ to site $y$, you cannot immediately go back from $y$ to $x$ along the same road.
Figure H.1: Sample Input 2. The illustration shows a valid trip using six roads. The road connecting sites 1 and 4 is used twice.
You are given a list of sites to possibly visit and the roads connecting them. Find the road trip with the shortest length that would keep your friends happy.
The road trip must start at site $1$, your home, and must visit at least one other site.
The input consists of:
If there is no road trip possible, output "impossible". Otherwise, output a your planned road trip, described by an integer $k$, the number of sites to visit on the road trip (including your home twice), followed by the $k$ sites, in the order of visiting them.
If there are multiple valid solutions, you may output any one of them.
6 7 1 2 2 3 1 3 1 4 4 5 5 6 1 6
4 1 3 2 1
12 13 1 2 2 3 1 4 4 5 5 6 6 7 4 7 1 8 8 9 9 10 10 11 11 12 9 12
7 1 4 5 6 7 4 1
3 2 1 2 2 3
impossible
4 3 2 3 3 4 2 4
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2025 H번