QOJ.ac

QOJ

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

#5321. 分享蛋糕

Statistics

Lunar Rose 是一个出生在宁静小镇的纯真善良的女孩,巧合的是,她出生那天正好是中秋节。因此,每逢生日,她都能享用两块蛋糕:一块是生日蛋糕,另一块是节日蛋糕。

今年,Lunar 想在这一天与她的男朋友 Jaddy 分享蛋糕,这难道不浪漫吗?然而悲剧发生了,Jaddy 又搞砸了:

当 Lunar 把两块蛋糕放在桌子上时,她想让 Jaddy 把蛋糕切开,这样他们两人就能各分到一半生日蛋糕和一半节日蛋糕。但 Jaddy 是个懒惰又冲动的人,他只是随手用刀把它们一起切开。结果虽然两块蛋糕都被切成了两半,但并不均匀。这有什么意义呢?Lunar 是个完美主义者,因为 Jaddy 的随意而对他非常生气。最终,Lunar 选择离开他。笨蛋 Jaddy!

Jaddy 感到非常后悔和痛苦。心软的 Lunar 不忍心让他如此痛苦,于是想再给他一次机会。然而,她为这项任务设定了一个严格的限制:Jaddy 只能用一刀将两块蛋糕分别平分成相等的两半。邪恶的 Rose 小姐!

这两块蛋糕都是凸多边形;桌子和刀都足够大、足够长,因此可以看作是无限大的平面和直线。请告诉 Jaddy 一个策略,即一条直线,满足 Lunar 切蛋糕的条件,这样他就能挽回她。

输入格式

输入数据的第一行是一个正整数 $T$ ($T \le 100$),表示测试用例的数量。接下来是 $T$ 个测试用例。每个测试用例包含两块蛋糕(多边形)的描述:每个多边形以一个整数 $n$ 开头,表示顶点的数量,随后是 $n$ 对整数 $(x, y)$,按逆时针顺序描述顶点的坐标。你可以假设每个多边形不超过 20 个顶点,且所有坐标都在 $[-1000, 1000]$ 范围内。此外,这两个多边形可以被一条直线分开,且不与该直线上的任何点接触。

输出格式

对于每个测试用例,输出两个实数 $k$ 和 $b$,并在前面加上用例编号,这意味着 Jaddy 应该沿着直线 $y = kx + b$ 切开蛋糕。保证答案中的 $k$ 和 $b$ 都在 $[-10000, 10000]$ 范围内。详见样例输出。任何相对或绝对误差在 $10^{-4}$ 以内的答案都是可接受的。

样例

样例输入 1

2
3
0 0
1 1
0 2
3
2 1
3 0
3 2
4
0 0
1 0
1 1
0 1
4
2 2
3 2
3 3
2 3

样例输出 1

Case #1: 0 1
Case #2: 1 0

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.