結果

問題 No.245 貫け!
ユーザー chocoruskchocorusk
提出日時 2020-09-18 22:33:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 4,093 ms / 5,000 ms
コード長 1,403 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 8,200 KB
最終ジャッジ日時 2023-09-04 11:11:58
合計ジャッジ時間 36,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,112 KB
testcase_01 AC 17 ms
8,020 KB
testcase_02 AC 17 ms
8,056 KB
testcase_03 AC 16 ms
8,096 KB
testcase_04 AC 16 ms
8,200 KB
testcase_05 AC 17 ms
8,052 KB
testcase_06 AC 18 ms
8,096 KB
testcase_07 AC 17 ms
8,028 KB
testcase_08 AC 56 ms
8,108 KB
testcase_09 AC 259 ms
8,028 KB
testcase_10 AC 363 ms
8,016 KB
testcase_11 AC 1,471 ms
8,164 KB
testcase_12 AC 4,079 ms
8,116 KB
testcase_13 AC 4,071 ms
8,104 KB
testcase_14 AC 4,089 ms
8,056 KB
testcase_15 AC 4,048 ms
8,064 KB
testcase_16 AC 4,049 ms
8,024 KB
testcase_17 AC 4,038 ms
8,096 KB
testcase_18 AC 4,093 ms
8,084 KB
testcase_19 AC 4,074 ms
8,064 KB
権限があれば一括ダウンロードができます

ソースコード

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