結果
問題 | 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 gcdfrom collections import defaultdictn = int(input())d = defaultdict(int)x = [0] * ny = [0] * nfor i in range(n):x[i], y[i] = map(int,input().split())x[i] *= 2y[i] *= 2def adjust(a, b):g = gcd(a, b)a //= gb //= gif a == 0 and b < 0: b = -bif b == 0 and a < 0: a = -aif a < 0:a = -ab = -breturn (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)] += 1ans = 0for t, c in d.items():xt, yt = adjust(-t[3], t[2])if (t[0], t[1], xt, yt) not in d:continueans += d[(t[0], t[1], xt, yt)] * cprint(ans // 2)