|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||3||3||3||100.000%|
The legendary land of Gondor had a network of sparks to quickly alert the entire land of an emergency.
Every spark is manned by an archer with several arrows and instruction in which order to light the other sparks.
More precisely, when his own spark is lit, the archer next to it lights his arrows and shoots one at every other spark that has not yet been lit, in the order in which his instructions say. The archer does so until he is out of arrows (or sparks to shoot at). The archers are very precise so every arrow hits its target. The time for an arrow to travel some distance is equal to that distance, while the time for anarcher to shoot all his arrows is negligible.
Sauron's army is approaching Gondor so the spark at Minas Tirith has been lit.
Write a program that, given the layout of sparks in the coordinate plane, the number of arrows and instructions for every archer, calculates the time indices at which each of the sparks will be lit.
The first line contains an integer N (1 ≤ N ≤ 100), the number of sparks. The sparks are numbered 1 to N. The spark in Minas Tirith, which has been lit at time 0, is spark number 1.
Each of the following N lines describes one spark. The description of one spark is composed of:
Note: The input will be such that no two sparks will be lit at the same time.
Output N decimal numbers, each on a single line, the times at which the sparks light up, in order from spark 1 to N. Your output must be accurate to ±0.001.
5 4 3 2 5 2 4 3 4 5 1 4 1 5 3 4 4 1 1 4 5 2 2 4 1 5 2 3 1 3 4 2 2 4 3 1
0.000000 2.000000 4.414214 2.414214 1.414214