結果
問題 |
No.2769 Number of Rhombi
|
ユーザー |
|
提出日時 | 2024-06-11 11:37:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,432 ms / 5,000 ms |
コード長 | 680 bytes |
コンパイル時間 | 333 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 333,384 KB |
最終ジャッジ日時 | 2024-06-11 11:38:51 |
合計ジャッジ時間 | 43,055 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
from collections import defaultdict from itertools import combinations from math import gcd N = int(input()) X, Y = map(list, zip(*[map(int, input().split()) for _ in range(N)])) def compress(dx, dy): if dx == 0: return (0, 1) if dy == 0: return (1, 0) if dx < 0: dx, dy = -dx, -dy g = abs(gcd(dx, dy)) return (dx // g, dy // g) d = defaultdict(int) for a, b in combinations(zip(X, Y), 2): x1, y1 = a x2, y2 = b d[(x1 + x2, y1 + y2, compress(x1 - x2, y1 - y2))] += 1 ans = 0 for a, b in combinations(zip(X, Y), 2): x1, y1 = a x2, y2 = b ans += d[(x1 + x2, y1 + y2, compress(y2 - y1, x1 - x2))] print(ans // 2)