結果
| 問題 |
No.2769 Number of Rhombi
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 23:05:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,571 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 1,083,872 KB |
| 最終ジャッジ日時 | 2024-12-21 01:26:33 |
| 合計ジャッジ時間 | 186,865 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 MLE * 2 |
| other | TLE * 3 MLE * 29 |
ソースコード
import math
ans = 0
memo = dict()
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
memo[(i,j)] = (tyuten, vec)
# 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
tyuten, vec = memo[(i,j)]
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)