結果

問題 No.245 貫け!
ユーザー chocorusk
提出日時 2020-09-18 22:33:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,403 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-06-22 10:02:51
合計ジャッジ時間 44,357 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

class Point:
    def __init__(self, x, y):
        self.x=x
        self.y=y
    def __add__(self, other):
        return Point(self.x+other.x, self.y+other.y)
    def __sub__(self, other):
        return Point(self.x-other.x, self.y-other.y)
    def __mul__(self, other):
        return Point(self.x*other, self.y*other)
    def dot(self, other):
        return self.x*other.x+self.y*other.y
    def det(self, other):
        return self.x*other.y-self.y*other.x
    def __eq__(self, other):
        return self.x==other.x and self.y==other.y
def is_intersect(p, q, r, s):
    a=(p-q).det(r-s)
    b=(p-r).det(r-s)
    if a==0:
        if b==0:
            return True
        else:
            return False
    if a>0:
        if 0<=b and b<=a:
            return True
        else:
            return False
    else:
        if 0>=b and b>=a:
            return True
        else:
            return False
n=int(readline())
abcd=list(map(int, read().split()))
ps=[Point(a, b) for a, b, c, d in zip(*[iter(abcd)]*4)]
qs=[Point(c, d) for a, b, c, d in zip(*[iter(abcd)]*4)]
pq=ps+qs
ans=0
for i, r in enumerate(pq):
    for s in pq[:i]:
        if r==s:
            continue
        cnt=sum(is_intersect(p, q, r, s) for p, q in zip(ps, qs))
        if ans<cnt:
            ans=cnt
print(ans)
0