結果

問題 No.1041 直線大学
ユーザー splash9494
提出日時 2024-05-08 17:53:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2024-12-14 23:53:29
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
ns = [tuple(map(int, input().split())) for _ in range(N)]

def is_linear(p1, p2, p3):
    return ((p1[0] - p3[0]) * (p1[1] - p2[1])) - ((p1[0] - p2[0]) * (p1[1] - p3[1])) == 0

lines = [[ns[0], ns[1]]]

for i, p in enumerate(ns[2:]):
    linear_points = set()
    current_points = set(ns[:2+i])
    for line in lines:
        if is_linear(*line[:2], p):
            line.append(p)
            linear_points |= set(line)
    
    lines.extend([[nonlinear, p] for nonlinear in (current_points - linear_points)])

print(max(len(line) for line in lines))
0