QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB 總分: 100

#2473. 选择题

统计

奶牛们正在参加一场选择题考试。但这并不是那种将每道题的选择结果单独评分并求和的标准考试,在这场考试中,你需要先将所有选择的向量求和,然后再进行评分。

具体来说,给定 $N$ ($2\le N\le 10^5$) 组二维平面上的整数向量,其中每个向量表示为一个有序对 $(x,y)$。请从每一组中选择一个向量,使得这些向量之和距离原点尽可能远。

保证向量总数不超过 $2\cdot 10^5$。每组的大小至少为 $2$,且同一组内的所有向量各不相同。同时保证每个 $x$ 和 $y$ 坐标的绝对值不超过 $\frac{10^9}{N}$。

输入格式

第一行包含 $N$,即组数。

每一组以 $G$ 开头,表示该组中向量的数量,随后是 $G$ 行,包含该组中的向量。相邻的组之间用空行分隔。

输出格式

输出最大可能的欧几里得距离的平方。

样例

样例输入 1

3

2
-2 0
1 0

2
0 -2
0 1

3
-5 -5
5 1
10 10

样例输出 1

242

说明

最优方案是从第一组选择 $(1,0)$,从第二组选择 $(0,1)$,从第三组选择 $(10,10)$。这些向量之和为 $(11,11)$,其距离原点的平方为 $11^2+11^2=242$。

子任务

  • 在测试点 1-5 中,向量总数不超过 $10^3$。
  • 在测试点 6-9 中,每组的大小恰好为 2。
  • 测试点 10-17 没有额外限制。

题目来源:Benjamin Qi

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.