Amplitude Hackathon Winter '24 Problem 6 - WhenTaken (Location)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 2.0s
Memory limit: 1G

Problem type

Eric has been challenged by his friends to yet another round of WhenTaken, the popular game where players guess when and where a picture was taken.

The Amplitude group has gotten so good at WhenTaken that they always get the year correct, so now they are refining their ability to guess the location that a picture was taken. Pictures can be taken in at any lattice point in the xy-plane as long as the absolute value of both the x and y coordinate is at most 10^3. If a picture was taken at point (x_p, y_p) and the group guesses that it was taken at point (x_g, y_g), then the group gets (x_p - x_g)^2 + (y_p - y_g)^2 penalty points.

Eric remembers every location that was guessed as well as the location of every picture in the last round of WhenTaken, but he does not remember which guess was for which picture. He wants to know the minimum and maximum number of penalty points that the group could have gotten.

Constraints

1 \le n \le 15

Input Specification

The first line of input contains a single integer, n.

The next n lines of input each contain two integers, x_p and y_p, indicating that some picture was taken at (x_p, y_p).

The next n lines of input each contain two integers, x_g and y_g, indicating that the group guessed some picture was taken at (x_g, y_g).

Output Specification

Output two integers, the minimum possible number of penalty points and the maximum possible number of penalty points.

Sample Input 1

2
0 0
1 1
0 0
1 1

Sample Output 1

0 4

Sample Explanation 1

If both guesses were correct, then the group got 0 penalty points. However, if both guesses were incorrect, then the group got 4 penalty points.

Sample Input 2

3
724 200
-649 334
549 -654
117 39
-43 -913
833 -342

Sample Output 2

1396971 5147231

Comments

There are no comments at the moment.