結果

問題 No.2331 Maximum Quadrilateral
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-05-31 22:53:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 560 ms / 2,000 ms
コード長 1,177 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 81,260 KB
最終ジャッジ日時 2023-08-28 01:40:10
合計ジャッジ時間 15,432 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 530 ms
81,116 KB
testcase_01 AC 387 ms
80,624 KB
testcase_02 AC 424 ms
80,508 KB
testcase_03 AC 511 ms
80,504 KB
testcase_04 AC 477 ms
80,452 KB
testcase_05 AC 505 ms
80,456 KB
testcase_06 AC 493 ms
81,260 KB
testcase_07 AC 456 ms
80,684 KB
testcase_08 AC 386 ms
80,612 KB
testcase_09 AC 369 ms
80,740 KB
testcase_10 AC 356 ms
80,748 KB
testcase_11 AC 371 ms
80,716 KB
testcase_12 AC 407 ms
80,436 KB
testcase_13 AC 370 ms
80,844 KB
testcase_14 AC 518 ms
80,528 KB
testcase_15 AC 218 ms
80,288 KB
testcase_16 AC 315 ms
80,680 KB
testcase_17 AC 186 ms
80,052 KB
testcase_18 AC 229 ms
80,328 KB
testcase_19 AC 194 ms
80,680 KB
testcase_20 AC 546 ms
80,744 KB
testcase_21 AC 546 ms
80,444 KB
testcase_22 AC 546 ms
80,624 KB
testcase_23 AC 550 ms
80,760 KB
testcase_24 AC 560 ms
80,640 KB
testcase_25 AC 107 ms
72,684 KB
testcase_26 AC 109 ms
72,864 KB
testcase_27 AC 106 ms
72,840 KB
testcase_28 AC 106 ms
72,900 KB
testcase_29 AC 106 ms
72,688 KB
testcase_30 AC 105 ms
72,920 KB
testcase_31 AC 104 ms
72,752 KB
testcase_32 AC 106 ms
72,840 KB
testcase_33 AC 104 ms
72,812 KB
testcase_34 AC 108 ms
72,908 KB
testcase_35 AC 107 ms
72,900 KB
testcase_36 AC 106 ms
72,904 KB
testcase_37 AC 107 ms
73,112 KB
testcase_38 AC 105 ms
72,860 KB
testcase_39 AC 105 ms
72,832 KB
testcase_40 AC 105 ms
72,828 KB
testcase_41 AC 107 ms
72,896 KB
testcase_42 AC 106 ms
72,868 KB
testcase_43 AC 104 ms
72,916 KB
testcase_44 AC 104 ms
72,812 KB
testcase_45 AC 107 ms
72,828 KB
testcase_46 AC 105 ms
72,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

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

ans = -1

def S(X,Y,Z):
    
    dx1,dy1 = Y[0]-X[0],Y[1]-X[1]
    dx2,dy2 = Z[0]-X[0],Z[1]-X[1]
    
    return dx1*dy2-dx2*dy1

INF = (1<<30)
def line(X,Y):
    x1,y1 = X
    x2,y2 = Y
    a = y2-y1
    b = x1-x2
    c = x2*y1 - x1*y2
    g = math.gcd(a,b)
    g = math.gcd(g,c)
    a //= g
    b //= g
    c //= g
    if a<0:
        a *= -1
        b *= -1
        c *= -1
    return (a,b,c)
for i in range(N-1):
    XI = XY[i]
    for j in range(i+1,N):
        XJ = XY[j]
        
        a,b,c = line(XI,XJ)
        m = INF
        M = -INF
        for k in range(N):
            if k==i:
                continue
            if k==j:
                continue
            Xk = XY[k]
            val = a*Xk[0]+b*Xk[1]+c
            if val<m:
                m = int(val)
                XS = Xk[:]
            if val>M:
                M = int(val)
                XT = Xk[:]

        tmp = S(XI,XJ,XS)-S(XI,XJ,XT)
        ans = max(ans,abs(tmp))

print(ans)
0