The National Geological Survey

ifnextchar ( ifnextchar (offsettrue(0pt,0pt) offsetfalse ifnextchar
[(0pt,0pt)(0pt,0pt) ifnextchar
[(0pt,0pt)(0pt,0pt)[l](0pt,0pt)(0pt,0pt)[l][] [r][image]

Masao’s life is very interesting. At one moment, he was the only
employee of the National Geological Survey (NGS) of an undisclosed
nation, well known for his attachment to long long traditions. Following
this noble traditionalism, Masao elaborated maps by carrying his good
ol’ theodolite (which he secretly—and lovingly—called Mady) across the
country, taking angle measures, and deducing from them the position of
the features of interest.

Masao started with two reference features, whose positions were known.
Then, he deduced from two angle measures the position of another
feature, etc. The terrain was flat, so Masao considered it a plane with
Cartesian coordinates, and happily used good ol’ trigonometry formulae
to locate the position of the features.

Can you write a program that, given all the measurements, prints the
coordinates of all the features of the country?

Input

Input begins with the name and the position (two real numbers x and y)
of the two reference features. Next come, in any order, the
measurements, each with the names of three features A, B and C and a
real number α, which indicate that the angle from vector $\vec{BA}$ to
vector $\vec{BC}$ measures α degrees, with positive values corresponding
to counterclockwise angles. Except for the two reference features, every
feature appears as C in exactly two measurements. The locations of A and
B are always already known at the time of the measurement. The names of
the features are all different.

The picture above corresponds to the second and last measurements given
in the sample input.

Output

Print, in lexicographical order, the name and the x and y coordinates of
every feature, with three digits after the decimal point. The input
cases have no precision issues.

Problem information

Author: Edgar Gonzàlez

Generation: 2026-01-25T12:18:30.624Z

© Jutge.org, 2006–2026.
https://jutge.org
