QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#22321. Oh Those Rollers

Estadísticas

Farmer John has installed a new winch that gives him mechanical advantage when lifting bales of hay into the barn. The winch was manufactured by the Rube Goldberg Winch Company and has way too many rollers to make any sense at all. The winch has a huge steel plate with a number of rollers whose ultimate source of power is the drive-roller whose location FJ has denoted as the origin (0,0). This roller drives a roller that drives another roller, etc. etc. until the final roller is driven. FJ is trying to find that final roller and wants to know which one it is.

Original diagram

FJ has recorded the $x_{i}$,$y_{i}$ $(-5,000 \le x_{i} \le 5,000; -5,000 \le y_{i} \le 5,000)$ coordinates and the radius $r_{i}$ $(3 \le r_{i} \le 1024)$ of each of the $N$ $(2 \le N \le 1080)$ rollers. Tell him the x,y coordinate of the last roller in the chain (the roller that is driven but drives no other roller). Every roller except the drive-roller is driven by exactly one other roller.

Input

  • Line 1: A single integer: $N$
  • Lines $2,\ldots,N+1$: Line $i+1$ describes roller $i$ with three space separated integers: $x_{i}$, $y_{i}$, and $r_{i}$

Output

  • Line 1: A single line with two space-separated integers that are respectively the x,y coordinates of the last roller in the chain of driven rollers.

Examples

Input 1

3
0 0 30
30 40 20
-15 100 55

Output 1

-15 100

Three rollers. First is at the origin with radius 30. It drives the roller at (30,40) whose radius is 20. That roller in turn drives the third roller located at (-15,100) with radius 55.

Problem credits: Rob Kolstad, 2008

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.