結果

問題 No.245 貫け!
ユーザー mkawa2mkawa2
提出日時 2020-01-30 16:50:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 989 ms / 5,000 ms
コード長 1,457 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,880 KB
最終ジャッジ日時 2023-10-14 08:31:35
合計ジャッジ時間 9,990 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,868 KB
testcase_01 AC 22 ms
8,876 KB
testcase_02 AC 20 ms
8,672 KB
testcase_03 AC 21 ms
8,780 KB
testcase_04 AC 21 ms
8,712 KB
testcase_05 AC 21 ms
8,828 KB
testcase_06 AC 21 ms
8,716 KB
testcase_07 AC 21 ms
8,780 KB
testcase_08 AC 29 ms
8,732 KB
testcase_09 AC 79 ms
8,880 KB
testcase_10 AC 103 ms
8,768 KB
testcase_11 AC 361 ms
8,768 KB
testcase_12 AC 966 ms
8,776 KB
testcase_13 AC 973 ms
8,744 KB
testcase_14 AC 965 ms
8,788 KB
testcase_15 AC 969 ms
8,728 KB
testcase_16 AC 989 ms
8,692 KB
testcase_17 AC 973 ms
8,744 KB
testcase_18 AC 971 ms
8,740 KB
testcase_19 AC 974 ms
8,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    def cross(x1,x2,y1,y2,k):
        vx,vy=x2-x1,y2-y1
        x3,y3,x4,y4=lines[k]
        vx3,vy3=x3-x1,y3-y1
        vx4,vy4=x4-x1,y4-y1
        if (vx*vy3-vy*vx3)*(vx*vy4-vy*vx4)>0:return 0
        else:return 1

    n=II()
    if n==1:
        print(1)
        exit()
    lines=[LI() for _ in range(n)]
    ans=0
    for i in range(n-1):
        l1=lines[i]
        for j in range(i+1,n):
            l2=lines[j]
            for p,q in [(0,0),(0,1),(1,0),(1,1)]:
                x1,y1=l1[p*2],l1[p*2+1]
                x2,y2=l2[q*2],l2[q*2+1]
                if (x1,y1)==(x2,y2):continue
                cur=sum(cross(x1,x2,y1,y2,k) for k in range(n))
                if cur>ans:ans=cur
    print(ans)

main()
0