結果
問題 | No.2769 Number of Rhombi |
ユーザー | Butterflv |
提出日時 | 2024-05-31 22:53:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,015 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,700 KB |
実行使用メモリ | 302,156 KB |
最終ジャッジ日時 | 2024-05-31 22:56:00 |
合計ジャッジ時間 | 127,011 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
59,648 KB |
testcase_01 | AC | 39 ms
53,272 KB |
testcase_02 | AC | 46 ms
61,496 KB |
testcase_03 | AC | 4,758 ms
274,472 KB |
testcase_04 | AC | 4,516 ms
274,732 KB |
testcase_05 | AC | 2,836 ms
215,352 KB |
testcase_06 | AC | 4,055 ms
257,408 KB |
testcase_07 | TLE | - |
testcase_08 | AC | 4,437 ms
268,232 KB |
testcase_09 | AC | 4,718 ms
272,756 KB |
testcase_10 | AC | 4,075 ms
269,172 KB |
testcase_11 | AC | 4,365 ms
277,896 KB |
testcase_12 | AC | 4,199 ms
295,772 KB |
testcase_13 | AC | 4,084 ms
298,648 KB |
testcase_14 | AC | 4,023 ms
300,056 KB |
testcase_15 | AC | 3,998 ms
300,376 KB |
testcase_16 | AC | 3,491 ms
288,660 KB |
testcase_17 | AC | 3,962 ms
302,156 KB |
testcase_18 | AC | 3,995 ms
301,320 KB |
testcase_19 | AC | 3,565 ms
290,564 KB |
testcase_20 | AC | 3,574 ms
289,624 KB |
testcase_21 | AC | 4,153 ms
301,668 KB |
testcase_22 | AC | 3,656 ms
290,400 KB |
testcase_23 | AC | 3,690 ms
288,984 KB |
testcase_24 | AC | 39 ms
54,544 KB |
testcase_25 | AC | 3,582 ms
286,980 KB |
testcase_26 | AC | 3,567 ms
288,260 KB |
testcase_27 | AC | 3,575 ms
290,832 KB |
testcase_28 | AC | 4,020 ms
300,672 KB |
testcase_29 | AC | 3,599 ms
290,104 KB |
testcase_30 | AC | 3,476 ms
289,072 KB |
testcase_31 | AC | 3,739 ms
283,852 KB |
testcase_32 | AC | 4,363 ms
267,752 KB |
testcase_33 | AC | 4,405 ms
268,252 KB |
testcase_34 | AC | 4,114 ms
269,112 KB |
ソースコード
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[1] = abs(vec[1]) if y1-y2==0: vec[0] = abs(vec[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 if inv_vec[0]==0: inv_vec[1] = abs(inv_vec[1]) if inv_vec[1]==0: inv_vec[0] = abs(inv_vec[0]) inv_vec = tuple(inv_vec) if point_info.get((tyuten, inv_vec))!=None: ans += point_info[(tyuten, inv_vec)] print(ans//8 if ans!=0 else 0) # print(point_info)