QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 64 MB 満点: 100

#23770. Searching for a Constellation

統計

Problem

You are searching for a constellation in a photo of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you want to find. However, there is a possibility that extra stars other than the stars constituting the constellation appear in the photo.

For example, the constellation in Figure $1$ is included in the photo in Figure $2$ (shown circled). Translating the coordinates of the stars of the given constellation by $2$ in the $x$-direction and $-3$ in the $y$-direction gives their positions in the photo.

Given the shape of the constellation you want to find and the positions of the stars appearing in the photo, write a program that finds the amounts by which the coordinates of the constellation must be translated to convert them to the coordinates in the photo.

fig1 fig2
Figure $1$: Constellation to find Figure $2$: Photo of the starry sky

Input

On the $1$-st line of the input, the number of stars $m$ constituting the constellation you want to find is written. On the following $m$ lines, integers indicating the $x$-coordinate and $y$-coordinate of the $m$ stars constituting the constellation you want to find are written separated by a space. On the $m+2$-th line, the number of stars $n$ appearing in the photo is written. On the following $n$ lines, integers indicating the $x$-coordinate and $y$-coordinate of the $n$ stars appearing in the photo are written separated by a space.

The positions of the $m$ stars constituting the constellation are all distinct. Also, the positions of the $n$ stars appearing in the photo are all distinct. Here, $1 \le m \le 200$ and $1 \le n \le 1000$. The $x$-coordinates and $y$-coordinates of the stars are all greater than or equal to $0$ and less than or equal to $1000000$.

Output

The output consists of $1$ line containing $2$ integers separated by a space. These represent by how much the coordinates of the constellation you want to find should be translated to become the coordinates in the photo. The first integer is the amount of translation in the $x$-direction, and the next integer is the amount of translation in the $y$-direction.

Sample Input and Output

Sample Input/Output $1$ corresponds to the figures above.

Sample Input 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

Sample Output 1

2 -3

Sample Input 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

Sample Output 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.