結果
問題 |
No.1041 直線大学
|
ユーザー |
![]() |
提出日時 | 2020-05-01 23:00:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 884 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-12-25 14:05:13 |
合計ジャッジ時間 | 3,392 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 15 WA * 22 |
ソースコード
from math import gcd from collections import defaultdict, Counter n = int(input()) XY = [] for i in range(n): x, y = map(int, input().split()) XY.append((x, y)) dictionary1 = defaultdict(int) dictionary2 = defaultdict(set) ans = set() if n >= 3: for i in range(n - 1): for j in range(i + 1, n): xi, yi = XY[i] xj, yj = XY[j] dx = xi - xj dy = yi - yj if dx < 0: dx *= -1 dy *= -1 g = gcd(dx, dy) dx //= g dy //= g dictionary1[(dx, dy)] += 1 dictionary2[(dx, dy)].add(i) dictionary2[(dx, dy)].add(j) DC = Counter(dictionary1) katamuki = DC.most_common()[0][0] for num in dictionary2[katamuki]: ans.add(num) print(len(list(ans))) elif n == 2: print(2) else: print(1)