시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 77 | 10 | 10 | 15.625% |
After a few particularly long afternoons of procrastinating in his box, playing video games all night long, Carl decided it was finally time to start his New Year’s Resolution – going to the bouldering gym.
There, he took to one of the easier walls and tried to make his way up. Unfortunately, he could never quite reach the top, as he would always run out of stamina and fall down.
While climbing, he noticed the holds all have different shapes with some of them being much harder to hold than others, so gripping them uses up different amounts of stamina. Frustrated, he asks one of the regulars at the bouldering hall how to scale the wall – you. Show him the shortest way up that he can take without running out of stamina.
The bouldering wall is a rectangular grid of cells of size 1 × 1 where holds can be installed. For this problem we do not consider the varying sizes of the holds, so you can assume them to be the shape of a singular point exactly in the middle of the cell. Carl can only move from one hold to another if their distance (the Euclidean distance between the centres of the cells) does not exceed his arms’ reach.
Figure B.1: Sample test case 1
The input consists of:
The first line corresponds to the top of the bouldering wall and the last line to the bottom.
A sequence of holds is a valid route for Carl if the following conditions are satisfied:
Output the total length of a shortest route Carl can climb to reach the topmost hold without running out of stamina. Your answer should have an absolute or relative error of at most 10−6. If it is not possible for Carl to reach the top, output impossible.
12 11 3 11 ........... ........3.. .......3.1. ........... .......2... .....2..... .1.1....... .....2..... .1......... ...2....... .1......... ...........
13.543203766865055
8 16 3 15 ......1......... ....1..1.1...... ..2........1.... ...2......1..... .....4.1..2..1.. ................ .......1........ ................
6.414213562373095
10 10 2 10 ...2...... .......... ...5.2.... .......... .....3.... ....5..... ..2....2.. ..1....... ....2..... ..1.......
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2019 B번