QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#2473. Multiple Choice Test

Statistics

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\le N\le 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.

Sample Input

3

2
-2 0
1 0

2
0 -2
0 1

3
-5 -5
5 1
10 10

Sample Output

242

It is optimal to select $(1,0)$ from the first group, $(0,1)$ from the second group, and $(10,10)$ from the third group. The sum of these vectors is $(11,11)$, which is squared distance $11^2+11^2=242$ from the origin.

Scoring

  • In test cases 1-5, the total number of vectors is at most $10^3$.
  • In test cases 6-9, every group has size exactly two.
  • Test cases 10-17 satisfy no additional constraints.

Problem credits: Benjamin Qi

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.