結果

問題 No.1041 直線大学
ユーザー splash9494
提出日時 2024-05-08 17:46:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 76,636 KB
最終ジャッジ日時 2024-12-14 23:40:22
合計ジャッジ時間 3,504 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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]]]
ns = ns[2:]

for i, p in enumerate(ns):
    linear_points = set()
    current_points = set(ns[: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