CCO '98 P4 - Scoring Curling

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type
Canadian Computing Competition: 1998 Stage 2, Day 2, Problem 1

The sport of curling is played in ends. In an end, two teams throw eight rocks each toward a circular target. The centre of the target is called the tee. The team that scores is the team whose rock is closest to the tee. The score for that team is the number of rocks belonging to it that are closer to the tee than any other rock from the opposing team, and no more than six feet from the tee. Rocks within 0.001 feet of the same distance to the tee are considered to be tied. A rock is not considered to be closer to the tee than a rock with which it is tied. If the nearest rocks for the two teams are tied or both more than six feet from the tee, the end is declared to be a blank end, and there is no score.

Assume that the tee is at the location whose coordinates are (0,0). The position of each rock is given as coordinate pairs (x,y) where x and y are in feet. For each of several games you are to determine which team wins, and its score.

Input Specification

The input consists of a line containing an integer n (1 \le n \le 100), followed by the information for n ends of curling. For each end, the positions of the eight rocks for team A are given followed by the positions of the eight rocks for team B. Each position is given on one line, the first decimal number being the x-coordinate and the second being the y-coordinate.

Output Specification

For each end, write a line containing the name of the team that wins (A or B) followed by a space followed by its score. If no team wins, write BLANK END.

Sample Input

1.000 1.000
2.000 2.000
3.000 3.000
4.000 4.000
5.000 5.000
6.000 6.000
7.000 7.000
8.000 8.000
0.100 1.000
0.900 -0.900
8.000 -8.000
-7.000 7.000
6.000 5.000
5.000 4.000
4.000 5.000
0.000 0.000

Sample Output

B 3


There are no comments at the moment.