結果
問題 | No.1041 直線大学 |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:17:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,088 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 82,912 KB |
実行使用メモリ | 75,168 KB |
最終ジャッジ日時 | 2025-03-20 21:18:42 |
合計ジャッジ時間 | 3,732 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
import mathfrom collections import defaultdictn = int(input())points = [tuple(map(int, input().split())) for _ in range(n)]if n <= 1:print(n)exit()max_res = 0for i in range(n):xi, yi = points[i]slope_counts = defaultdict(int)for j in range(n):if i == j:continuexj, yj = points[j]dx = xj - xidy = yj - yig = math.gcd(abs(dx), abs(dy))if g == 0:dx_g = 0dy_g = 0else:dx_g = dx // gdy_g = dy // g# Normalize the directionif dx_g == 0:# Vertical line, ensure dy is positiveif dy_g < 0:dy_g = -dy_gelse:if dx_g < 0:dx_g = -dx_gdy_g = -dy_gslope = (dx_g, dy_g)slope_counts[slope] += 1current_max = 0if slope_counts:current_max = max(slope_counts.values())max_res = max(max_res, current_max + 1) # include the current point iprint(max_res)