multiplechoice

Multiple Choice Test

The cows are taking a multiple choice test. But instead of a standard test where your selected choices are scored for each question individually and then summed, in this test your selected choices are summed before being scored.

Specifically, you are given \(N\) \((2 \leq N \leq 10^5)\) groups of integer vectors on the 2D plane, where each vector is denoted by an ordered pair \((x, y)\). Choose one vector from each group such that the sum of the vectors is as far away from the origin as possible.

It is guaranteed that the total number of vectors is at most \(2 \cdot 10^5\). Each group has size at least \(2\), and within a group, all vectors are distinct. It is also guaranteed that every \(x\) and \(y\) coordinate has absolute value at most \(\frac{10^9}{N}\).

Input format

The first line contains \(N\), the number of groups.
Each group starts with \(G\), the number of vectors in the group, followed by \(G\) lines containing the vectors in that group. Consecutive groups are separated by newlines.

Output format

The maximum possible squared Euclidean distance.

Limits

Subtask # Score Constraints
1 30 The total number of vectors is at most \(10^3\).
2 24 Every group has size exactly two.
3 46 No additional constraints

Samples

Sample Input 1 Sample Output 1
3

2
-2 0
1 0

2
0 -2
0 1

3
-5 -5
5 1
10 10
242

Submitting to 'multiplechoice'


You're not logged in! Click here to login


Submitting to 'multiplechoice'


You're not logged in! Click here to login


Submitting .cpp to 'multiplechoice'


You're not logged in! Click here to login


Compile Errors


							
Time Limit: 2 Seconds
Memory Limit: 1024MB
No. of ACs: 6
Your best score: 0
Source: USACO 2022 Jan, Platinum

Subtask Score
1 30
2 24
3 46