結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-09-18 22:34:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 309 ms / 5,000 ms |
| コード長 | 1,403 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 78,404 KB |
| 最終ジャッジ日時 | 2024-06-22 10:03:01 |
| 合計ジャッジ時間 | 4,273 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
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)
chocorusk