結果

問題 No.2012 Largest Triangle
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-07-15 22:05:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,493 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 107,852 KB
最終ジャッジ日時 2023-09-10 02:02:24
合計ジャッジ時間 21,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,448 KB
testcase_01 AC 72 ms
71,448 KB
testcase_02 AC 72 ms
71,312 KB
testcase_03 WA -
testcase_04 AC 74 ms
71,540 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 73 ms
71,376 KB
testcase_08 WA -
testcase_09 AC 73 ms
71,268 KB
testcase_10 AC 73 ms
71,232 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""


2012:

一番素直そうな問題?
偏角ソート
Aを決め打った時、OAから最も遠い点をすぐに求めればよい



"""

import sys
from sys import stdin

def Monotone_Chain(vlis):

    def upstate(a,b,c):
        B = (b[0]-a[0],b[1]-a[1])
        C = (c[0]-a[0],c[1]-a[1])
        return B[1] * C[0] < C[1] * B[0]

    def downstate(a,b,c):
        B = (b[0]-a[0],b[1]-a[1])
        C = (c[0]-a[0],c[1]-a[1])
        return B[1] * C[0] > C[1] * B[0]

    N = len(vlis)
    vc = [vlis[i] for i in range(N)]

    if N >= 3:
        
        vc.sort()

        uv = []

        for v in vc:
            uv.append(v)
            while len(uv) >= 3 and upstate(uv[-3],uv[-2],uv[-1]):
                del uv[-2]

        dv = []
        for v in vc:
            dv.append(v)
            while len(dv) >= 3 and downstate(dv[-3],dv[-2],dv[-1]):
                del dv[-2]


        #print (uv,dv)
        tmp = dv[1:-1]
        tmp.reverse()
        uv += tmp

        return uv

    else:
        return vc

ans = 0
def calc(p1,p2):
    global ans

    ret = abs(p1[0]*p2[1] - p1[1]*p2[0])

    ans = max(ans,ret)

    return ret

N = int(stdin.readline())

vlis = []

for i in range(N):

    x,y = map(int,stdin.readline().split())
    vlis.append( (x,y,i) )

vlis = Monotone_Chain(vlis)

ans = 0


last = 0

m = len(vlis)
for i in range(3*m):

    while last <= i and calc(vlis[(last+1)%m],vlis[i%m]) > calc(vlis[last%m],vlis[i%m]):
        last += 1

print (ans)

    
0