CCO '00 P6 - Extension Cords

View as PDF

Submit solution

Points: 12
Time limit: 2.0s
Memory limit: 64M

Problem types
Canadian Computing Competition: 2000 Stage 2, Day 2, Problem 3

Harry the handyman needs to plug in his table saw and his arc welder at his work location. Since they each draw a lot of current, he must plug them into outlets on two different electrical circuits. Several outlets are available; each outlet is on one of several circuits. Harry has a number of extension cords of various lengths. Can Harry join some of his extension cords together so as to plug in the saw and the welder to different circuits at the same time?

Input Specification

The first line of input contains four numbers: x, y, n, m. x and y, both real numbers with an absolute value of at most 2\,000 given with exactly one decimal place, give the coordinates of Harry's work location. n, an integer between 1 and 100, gives the number of extension cords. m, an integer between 1 and 100, gives the number of outlets. For each extension cord, a line follows which gives its length, a positive integer less than 500. For each outlet, a line follows containing a, b, and c. a and b, both real numbers with an absolute value of at most 2\,000 given with exactly one decimal place, give the coordinates of the outlet. c, an integer between 1 and 10\,000, gives the circuit number to which the outlet is connected.

There are no obstructions on the floor so Harry can run a string of cords directly from any outlet to his work location.

Output Specification

If Harry can plug in his equipment, print the coordinates of any pair of outlets to which Harry can with exactly one decimal place, in the format below. Otherwise, print Harry is helpless..

Sample Input

100.0 100.0 3 3
7
8
6
100.0 106.0 1
110.0 90.0 2
89.0 111.0 3

Sample Output

Harry can connect to outlets at (100.0, 106.0) and (110.0, 90.0).

Comments

There are no comments at the moment.