Back
Close
  • 86

What will I learn?

GeometryCollision Detection

Statement

 Goal

A group of your friends want to have a dart throwing competition with a unique target. They've asked you, their tech savvy friend, to automate the scoring as they often squabble over scoring, and have trouble keeping track of who's turn it is to throw.

The target is a square. The square has a circle inscribed within whose diameter matches the width of the square. The circle, in turn, encompasses a diamond whose width from corner to corner matches the circle's diameter.

Darts landing within the square but not within the circle or diamond are worth 5 points. Darts landing within the circle but not within the diamond are worth 10 points. Darts landing within the diamond are worth 15 points.

In the event of a tie, competitors should be ordered as they were in the name list, so competitors appearing earlier in the name list are listed earlier in ties.

Note: darts landing on the edge of a shape are considered within the shape.
Note: The center of the square, circle, and diamond are at (0,0).
Input
Line 1: SIZE of square as integer.
Line 2: The number of competitors in name list, N
Next N lines: name of a single competitor in name list.
Line N+1: Number of throws, T
Next T: Lines: Name of competitor, integer x coordinate, integer y coordinate of throw each separated by a space name X Y.
Output
A line with competitor's name, a space, and that competitor's score, in descending order by score.
Constraints
10 <= SIZE <= 100
1 <= N <= 10
1 <= T <= 50
-300 <= X <= 300
-300 <= Y <= 300
Example
Input
20
2
Will
Jill
4
Will 0 0
Jill 0 0
Will 20 20
Jill 0 0
Output
Jill 30
Will 15
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants