結果
問題 | No.2769 Number of Rhombi |
ユーザー | Butterflv |
提出日時 | 2024-05-31 22:50:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,848 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 81,964 KB |
実行使用メモリ | 302,400 KB |
最終ジャッジ日時 | 2024-05-31 22:52:16 |
合計ジャッジ時間 | 122,672 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
60,172 KB |
testcase_01 | AC | 38 ms
53,204 KB |
testcase_02 | AC | 46 ms
60,652 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 3,425 ms
290,064 KB |
testcase_21 | AC | 4,019 ms
301,936 KB |
testcase_22 | WA | - |
testcase_23 | AC | 3,471 ms
288,932 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 3,552 ms
290,448 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
ソースコード
import math ans = 0 N=int(input()) P = [] for i in range(N): x, y = map(int, input().split()) P.append((x, y)) point_info = dict() for i in range(N): for j in range(N): if P[i]==P[j]: continue x1, y1 = P[i] x2, y2 = P[j] tyuten_x = [x1+x2, 2] if (x1+x2)%2==0: tyuten_x = [(x1+x2)//2, 1] tyuten_x = tuple(tyuten_x) tyuten_y = [y1+y2, 2] if (y1+y2)%2==0: tyuten_y = [(y1+y2)//2, 1] tyuten_y = tuple(tyuten_y) tyuten = (tyuten_x, tyuten_y) # 方向 vec vec = [x1-x2, y1-y2] if x1-x2==0: vec[0]=0 if y1-y2==0: vec[1]=0 if vec[1]<0: vec[0]*=-1; vec[1]*=-1 g = math.gcd(abs(vec[0]), abs(vec[1])) vec[0]//=g; vec[1]//=g vec = tuple(vec) if point_info.get((tyuten, vec))==None: point_info[(tyuten, vec)] = 0 point_info[(tyuten, vec)] += 1 # for key in point_info: # point_info[key]=dict(point_info[key]) # point_info = dict(point_info) # for key in point_info: # print(key, point_info[key]) for i in range(N): for j in range(N): if P[i]==P[j]: continue x1, y1 = P[i] x2, y2 = P[j] tyuten_x = [x1+x2, 2] if (x1+x2)%2==0: tyuten_x = [(x1+x2)//2, 1] tyuten_x = tuple(tyuten_x) tyuten_y = [y1+y2, 2] if (y1+y2)%2==0: tyuten_y = [(y1+y2)//2, 1] tyuten_y = tuple(tyuten_y) tyuten = (tyuten_x, tyuten_y) # 方向 vec vec = [x1-x2, y1-y2] if x1-x2==0: vec[0]=0 if y1-y2==0: vec[1]=0 if vec[1]<0: vec[0]*=-1; vec[1]*=-1 g = math.gcd(abs(vec[0]), abs(vec[1])) vec[0]//=g; vec[1]//=g vec = tuple(vec) inv_vec = [vec[1], vec[0]*(-1)] if inv_vec[1]<0: inv_vec[0]*=-1; inv_vec[1]*=-1 inv_vec = tuple(inv_vec) if point_info.get((tyuten, inv_vec))!=None: ans += point_info[(tyuten, inv_vec)] print(ans//8 + 1 if ans!=0 else 0)