## DMOPC '16 Contest 3 P4 - Serpent's Search

View as PDF

Points: 17 (partial)
Time limit: 1.8s
Java 8 5.0s
Python 5.0s
Memory limit: 64M
Java 8 256M
Python 256M

Authors:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

After his new game idea was finally solved, jackyliao123 returns home from school and unwinds in his room for the rest of the evening. He was in the middle of downloading more Rem when his phone rang. It was his old friend, who had called to ask for advice on his side project!

In Slither.io, the player is a snake who tries to survive in a world of legless reptiles. Because one dies in the event of a head-on collision with another player, jackyliao123 is tasked with implementing a component of the path-finding algorithm which actively seeks to avoid such collisions.

The current instance of time in the game contains other players, representing the points which the player character wants to avoid. However, the player has instances of the game open and as a result, must update the game-state for their path-finding.

The opposing snakes and the queried snakes are represented by an ordered pair in the Cartesian plane.

For each of the queried snakes controlled by the player, jackyliao123 must determine the squared distance of the nearest point from the opposing points , and the number of those points which have a squared distance equal to .

Can you write a program to help jackyliao123 help his friend?

#### Input Specification

The first line of the input will contain a single integer , denoting the number of opposing snakes to consider.

The next lines will each contain two space-separated integers , representing the location of the opponent.

The next line will contain a single integer , denoting the number of Slither.io games the player is playing simultaneously.

The next lines will each contain two space-separated integers , representing the location of the player character.

#### Output Specification

Your program should output two space-separated integers on a single line for each of the queries.

The first integer represents the square of the Euclidean distance between the queried point and the closest of the snakes.

The second integer represents the number of points from the set of opponents whose squared distance from the queried point is equal to .

#### Sample Input

3
0 0
98 0
100 0
2
1 0
49 0

#### Sample Output

1 1
2401 2