Curling
InterviewTime limit2sMemory limit1024 MB
For each end, find the team with the stone closest to the origin and count its stones closer than every opposing stone, then print the totals as a:b.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Curling (from the Scots word curr) is a team sport played on an ice sheet.
Wikipedia
Curling has been an Olympic sport since 1998. While watching the Winter Olympics in Vancouver, the Prime Minister of Flatland became very interested in the sport. He decided that Flatland must take part in curling competitions at the 2014 Olympics, for both the women's and the men's events.
Later it turned out that the country had no curling rinks at all. The Prime Minister took the matter seriously and ordered at least one rink to be built in each large city. The first rink to be built is in the center of Sen-Flatburg, the capital. It is almost finished, and the largest scoreboard available has already been bought, but no software has been written for it yet. Your task is to write a program that calculates the current score of a curling game.
Two teams play curling. A game consists of ten periods called ends. If the score is tied after ten ends, an extra eleventh end is played. In each end, the teams take turns playing stones. During an end, some stones may leave the playing area, and they are then removed from the sheet.
After each team has played all eight stones, the end is scored. The team whose stone is closest to the center of the house wins the end. That team gets one point for each of its stones that is strictly closer to the center than any stone of the opponent. The current score is the sum of the points from all completed ends.
Several ends have been played in a game. For each end, the final positions of the stones still in play are given. Determine the current score.
Input
The first line contains a single integer (), the number of completed ends. Each end follows in this format.
The first line of an end contains two integers and (), the numbers of stones still in play that belong to the first and second teams. The next lines each contain two integers, the coordinates of a stone of the first team. The next lines each contain two integers, the coordinates of a stone of the second team. All coordinates have absolute values not greater than 1000. No two stones in one end are at the same point.
The center of the house is at the origin .
Output
Print the current score in the form a:b, where is the current score of the first team and is the current score of the second team.