結果

問題 No.1041 直線大学
ユーザー Geckoちゃん
提出日時 2020-05-16 18:29:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-16 08:03:14
合計ジャッジ時間 2,697 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
n=int(input())

ps = []
for _ in range(n):
    a,b=map(int,input().split())
    ps.append((a,b))

from itertools import combinations

pset = set()

special_x = set()
special_y = set()
for p1, p2 in combinations(ps,2):
    if p2[0] != p1[0]:
        katamuki = (p2[1] - p1[1])/(p2[0] - p1[0])
        takasa = p1[1] - katamuki*p1[0]
        pset.add((katamuki, takasa))
    if p2[0] == p1[0]:
        special_x.add(p1[0])
    if p2[1] == p1[1]:
        special_y.add(p1[0])
        
cs = []
for katamuki, takasa in pset:
    c = 0
    for p in ps:
        if abs(p[1] - (p[0]*katamuki + takasa)) < 0.0001:
            c += 1
    cs.append(c)
for special in special_x:
    c = 0
    for p in ps:
        if p[0] == special:
            c += 1
    cs.append(c)
for special in special_y:
    c = 0
    for p in ps:
        if p[1] == special:
            c += 1
    cs.append(c)
print(max(cs))
0