JOI 2008 予選 4 – 星座探し

AtCoderなど過去問

JOI 2008 予選 4 – 星座探し

m = int(input())
seek = [tuple(map(int,input().split())) for i in range(m)]
n = int(input())
pict = [tuple(map(int,input().split())) for i in range(n)]

pict_set = set(pict)
seek.sort()
o = seek[0]
seek_relation = []
x,y = seek[0]

for i in range(1,len(seek)):
    sx,sy = seek[i][0]-x,seek[i][1]-y
    seek_relation.append((sx,sy))
    x,y = x+sx,y+sy

seek_relation.append((seek[0][0]-x,seek[0][1]-y))

for i in pict:
    x,y = i
    for j in seek_relation:
        x,y = x + j[0] , y + j[1]
        if not (x,y) in pict_set:
            break
        elif j == seek_relation[-1]:
            ansx,ansy = x-seek[0][0],y-seek[0][1]

print(f'{ansx} {ansy}')

コメント

タイトルとURLをコピーしました