QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 64 MB مجموع النقاط: 100

#23770. 寻找星座

الإحصائيات

题目描述

你正在从星空照片中寻找星座。照片中一定恰好包含一个与想要寻找的星座形状、方向和大小完全相同的图形。但是,照片中除了构成星座的星星之外,还可能拍进了多余的星星。

例如,图 $1$ 的星座包含在图 $2$ 的照片中(已用圆圈标出)。将给定星座中星星的坐标在 $x$ 方向上平移 $2$,在 $y$ 方向上平移 $-3$,就得到了照片中的位置。

当给定想要寻找的星座形状以及照片中拍到的星星位置时,请编写程序求出为了将星座的坐标转换为照片中的坐标所需平移的量。

fig1 fig2
图 $1$:想要寻找的星座 图 $2$:星空照片

输入格式

输入的第 $1$ 行写有构成想要寻找的星座的星星个数 $m$。接下来的 $m$ 行中,以空格分隔写有表示构成想要寻找的星座的 $m$ 颗星星的 $x$ 坐标和 $y$ 坐标的整数。第 $m+2$ 行写有照片中拍到的星星个数 $n$。接下来的 $n$ 行中,以空格分隔写有表示照片中拍到的 $n$ 颗星星的 $x$ 坐标和 $y$ 坐标的整数。

构成星座的 $m$ 颗星星的位置互不相同。此外,照片中拍到的 $n$ 颗星星的位置也互不相同。满足 $1 \le m \le 200$,$1 \le n \le 1000$。星星的 $x$ 坐标和 $y$ 坐标均为 $0$ 以上 $1000000$ 以下。

输出格式

输出由 $1$ 行组成,包含以空格分隔的 $2$ 个整数。它们表示将想要寻找的星座的坐标平移多少后可以变成照片中的坐标。第一个整数是在 $x$ 方向上平移的量,下一个整数是在 $y$ 方向上平移的量。

输入输出样例

输入输出样例 $1$ 对应上方的图示。

输入样例 1

5
8 5
6 4
4 3
7 10
0 10
10
10 5
2 7
9 7
8 10
10 2
1 2
8 1
6 7
6 0
0 9

输出样例 1

2 -3

输入样例 2

5
904207 809784
845370 244806
499091 59863
638406 182509
435076 362268
10
757559 866424
114810 239537
519926 989458
461089 424480
674361 448440
81851 150384
459107 795405
299682 6700
254125 362183
50795 541942

输出样例 2

-384281 179674

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.