結果

問題 No.245 貫け!
ユーザー titiatitia
提出日時 2022-08-11 00:56:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 2,142 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-21 10:21:25
合計ジャッジ時間 19,366 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

# 交差判定には外積を使うんだったよなー、と思って解説を見た。

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

def outer_product(x,y,z,w):
    return x*w-y*z

ANS=0

for x,y,_,_ in A:
    for _,_,z,w in A:
        if x==z and y==w:
            continue

        score=0

        for p,q,r,s in A:
            if outer_product(z-x,w-y,p-x,q-y)*outer_product(z-x,w-y,r-x,s-y)<=0:
                score+=1
                
        ANS=max(ANS,score)

for x,y,_,_ in A:
    for z,w,_,_ in A:
        if x==z and y==w:
            continue

        score=0

        for p,q,r,s in A:
            if outer_product(z-x,w-y,p-x,q-y)*outer_product(z-x,w-y,r-x,s-y)<=0:
                score+=1
                
        ANS=max(ANS,score)

print(ANS)
            
0