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.