2000 Canadian Computing Competition, Stage 2
Day 2, Problem 3: Extension CordsHarry 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?
InputThe first line of input contains four numbers: x, y, n, m. x and y, both real numbers, 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, give the coordinates of the outlet. c, an integer, 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.
OutputIf Harry can plug in his equipment, print the coordinates of the first pair of outlets to which Harry can connect, in the format below. Otherwise, print "Harry is helpless."
We define the "first pair" of outlets as the pair which has the earliest outlest (in the order of the input file).
That is, a pair comes before another pair if the first outlet of the first pair is earlier in the input than the first outlet of the second pair. If there is a tie with the first outlet, then consider the orders of the second outlets.
100.0 100.0 3 3 7 8 6 100.0 106.0 1 110.0 90.0 2 89.0 111.0 3
Harry can connect to outlets at (100.0, 106.0) and (110.0, 90.0).
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 19, 2009
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3