結果
問題 | No.2769 Number of Rhombi |
ユーザー |
![]() |
提出日時 | 2024-05-31 23:03:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,069 ms / 5,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 340 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 245,644 KB |
最終ジャッジ日時 | 2024-12-21 01:18:23 |
合計ジャッジ時間 | 30,414 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
from math import gcd from collections import defaultdict n = int(input()) d = defaultdict(int) x = [0] * n y = [0] * n for i in range(n): x[i], y[i] = map(int,input().split()) x[i] *= 2 y[i] *= 2 def adjust(a, b): g = gcd(a, b) a //= g b //= g if a == 0 and b < 0: b = -b if b == 0 and a < 0: a = -a if a < 0: a = -a b = -b return (a, b) for i in range(n): for j in range(i + 1, n): xt, yt = adjust(x[j] - x[i], y[j] - y[i]) d[( (x[i] + x[j]) // 2, (y[i] + y[j]) // 2, xt, yt )] += 1 ans = 0 for t, c in d.items(): xt, yt = adjust(-t[3], t[2]) if (t[0], t[1], xt, yt) not in d: continue ans += d[(t[0], t[1], xt, yt)] * c print(ans // 2)