Submission #23847490
Source Code Expand
import math
N = int(input())
S = [tuple(map(float,input().split())) for i in range(N)]
T = [tuple(map(float,input().split())) for i in range(N)]
def trans(X, i):
# 点集合Xを、X[i]が減点になるように平行移動した集合を返す
return [(p[0]-X[i][0], p[1]-X[i][1]) for p in X]
def dist(p, q):
# 2点p,qの距離の2乗
return (p[0]-q[0])**2 + (p[1]-q[1])**2
def rot(X, theta):
# 点集合Xを、theta回転する
ret = []
for x, y in X:
xx = x*math.cos(theta) + y*-math.sin(theta)
yy = x*math.sin(theta) + y* math.cos(theta)
ret.append((xx, yy))
return ret
def is_ok(S, T):
# 2つの点集合S,Tが一致しているか判定する
for p in S:
flag = False
for q in T:
if abs(p[0]-q[0])<0.01 and abs(p[1]-q[1])<0.01:
flag = True
break
if not flag: return False
return True
if N==1:
print("Yes")
exit()
# S[0]が原点になるように先にずらしておく
transS = trans(S,0)
r = dist(S[0],S[1])
thetaS=math.atan2(transS[1][1],transS[1][0])
# (i,j)の組を全探索
for i in range(N):
for j in range(N):
# S[0],S[1] 間の距離が T[i],T[j] 間の距離が異なるならダメNo
if dist(T[i],T[j])!=r: continue
# 平行移動
transT = trans(T,i)
thetaT = math.atan2(transT[j][1],transT[j][0])
# 回転移動
rotS = rot(transS, thetaT-thetaS)
# チェック
if is_ok(rotS,transT):
print("Yes")
exit()
print("No")
Submission Info
| Submission Time | |
|---|---|
| Task | D - Congruence Points |
| User | kyopro_friends |
| Language | PyPy3 (7.3.0) |
| Score | 400 |
| Code Size | 1469 Byte |
| Status | AC |
| Exec Time | 77 ms |
| Memory | 69476 KiB |
Judge Result
| Set Name | Sample | All | after_contest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | 0 / 0 | ||||||
| Status |
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt, example3.txt |
| All | example0.txt, example1.txt, example2.txt, example3.txt, 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, killer_T_01.txt, killer_T_02.txt, killer_T_03.txt, killer_T_04.txt, killer_T_05.txt, killer_T_06.txt, killer_T_07.txt, killer_T_08.txt, killer_T_09.txt, killer_T_10.txt, killer_T_11.txt, killer_T_12.txt, killer_T_13.txt, killer_T_14.txt |
| after_contest | after_contest_01.txt, after_contest_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 74 ms | 62472 KiB |
| 001.txt | AC | 71 ms | 68620 KiB |
| 002.txt | AC | 71 ms | 68948 KiB |
| 003.txt | AC | 55 ms | 66680 KiB |
| 004.txt | AC | 52 ms | 62864 KiB |
| 005.txt | AC | 73 ms | 68988 KiB |
| 006.txt | AC | 70 ms | 68812 KiB |
| 007.txt | AC | 73 ms | 69132 KiB |
| 008.txt | AC | 61 ms | 67896 KiB |
| 009.txt | AC | 57 ms | 66528 KiB |
| 010.txt | AC | 59 ms | 66120 KiB |
| 011.txt | AC | 52 ms | 63712 KiB |
| 012.txt | AC | 66 ms | 68776 KiB |
| 013.txt | AC | 69 ms | 68792 KiB |
| 014.txt | AC | 52 ms | 63024 KiB |
| 015.txt | AC | 68 ms | 69004 KiB |
| 016.txt | AC | 55 ms | 65416 KiB |
| 017.txt | AC | 57 ms | 66384 KiB |
| 018.txt | AC | 57 ms | 65200 KiB |
| 019.txt | AC | 52 ms | 62516 KiB |
| 020.txt | AC | 58 ms | 65656 KiB |
| 021.txt | AC | 56 ms | 63268 KiB |
| 022.txt | AC | 50 ms | 63288 KiB |
| 023.txt | AC | 76 ms | 69148 KiB |
| 024.txt | AC | 53 ms | 62996 KiB |
| 025.txt | AC | 59 ms | 66416 KiB |
| 026.txt | AC | 55 ms | 63856 KiB |
| 027.txt | AC | 57 ms | 65112 KiB |
| 028.txt | AC | 50 ms | 63132 KiB |
| 029.txt | AC | 53 ms | 63572 KiB |
| 030.txt | AC | 55 ms | 62312 KiB |
| 031.txt | AC | 52 ms | 62460 KiB |
| 032.txt | AC | 50 ms | 62468 KiB |
| 033.txt | AC | 55 ms | 62348 KiB |
| 034.txt | AC | 52 ms | 62468 KiB |
| 035.txt | AC | 52 ms | 62768 KiB |
| 036.txt | AC | 56 ms | 62556 KiB |
| 037.txt | AC | 55 ms | 63020 KiB |
| 038.txt | AC | 59 ms | 66684 KiB |
| 039.txt | AC | 63 ms | 68488 KiB |
| 040.txt | AC | 51 ms | 63108 KiB |
| 041.txt | AC | 52 ms | 62924 KiB |
| 042.txt | AC | 50 ms | 62924 KiB |
| 043.txt | AC | 52 ms | 62980 KiB |
| 044.txt | AC | 55 ms | 63032 KiB |
| 045.txt | AC | 53 ms | 63108 KiB |
| after_contest_01.txt | AC | 53 ms | 62984 KiB |
| after_contest_02.txt | AC | 50 ms | 63132 KiB |
| example0.txt | AC | 50 ms | 63076 KiB |
| example1.txt | AC | 52 ms | 62800 KiB |
| example2.txt | AC | 53 ms | 62908 KiB |
| example3.txt | AC | 56 ms | 63068 KiB |
| killer_T_01.txt | AC | 50 ms | 62928 KiB |
| killer_T_02.txt | AC | 52 ms | 62796 KiB |
| killer_T_03.txt | AC | 53 ms | 62764 KiB |
| killer_T_04.txt | AC | 50 ms | 63112 KiB |
| killer_T_05.txt | AC | 77 ms | 69476 KiB |
| killer_T_06.txt | AC | 58 ms | 68148 KiB |
| killer_T_07.txt | AC | 53 ms | 62940 KiB |
| killer_T_08.txt | AC | 51 ms | 62996 KiB |
| killer_T_09.txt | AC | 69 ms | 69080 KiB |
| killer_T_10.txt | AC | 62 ms | 68512 KiB |
| killer_T_11.txt | AC | 67 ms | 68680 KiB |
| killer_T_12.txt | AC | 64 ms | 68276 KiB |
| killer_T_13.txt | AC | 55 ms | 62900 KiB |
| killer_T_14.txt | AC | 56 ms | 63016 KiB |