A839.Multiple Choice Test--Platinum

省选/NOI-

USACO

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

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 NN (2N1052\le N\le 10^5) groups of integer vectors
on the 2D plane, where each vector is denoted by an ordered pair (x,y)(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 21052\cdot 10^5.
Each group has size at least 22, and within a group, all vectors are
distinct. It is also guaranteed that every xx and yy coordinate has absolute
value at most 109N\frac{10^9}{N}.

输入格式

The first line contains NN, the number of groups.
Each group starts with GG, the number of vectors in the group, followed by
GG lines containing the vectors in that group. Consecutive groups are
separated by newlines.

输出格式

The maximum possible squared Euclidean distance.

输入输出样例

  • 输入#1

    3
    2
    -2 0
    1 0
    2
    0 -2
    0 1
    3
    -5 -5
    5 1
    10 10
    

    输出#1

    242
    

说明/提示

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

首页