結果

問題 No.1144 Triangles
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-12-29 15:17:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,416 KB
最終ジャッジ日時 2023-12-29 15:17:38
合計ジャッジ時間 35,077 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,988 KB
testcase_01 AC 44 ms
55,988 KB
testcase_02 AC 44 ms
55,988 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 51 ms
55,988 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 AC 166 ms
77,912 KB
testcase_20 AC 72 ms
76,588 KB
testcase_21 AC 71 ms
76,588 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 396 ms
83,180 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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)]


mod = 10**9 + 7

S = 0

for i in range(N-2):
    xi,yi = XY[i]
    xy = []
    for j in range(i+1,N):
        xj,yj = XY[j]
        xt,yt = xj-xi,yj-yi
        xy.append((math.atan2(yt,xt),xt,yt))
    xy.sort()
    SY = list(accumulate([0]+
                         [x for _,x,_ in xy]))
    SX = list(accumulate([0]+
                         [x for _,_,x in xy]))
    n = len(xy)

    for j in range(n-1):

        _,xj,yj = xy[j]

        is_ok = lambda X: (xj*X[2] - yj*X[1])>=0

        y = n-1
        x = j
        if is_ok(xy[y]):
            S = (S 
                 + xj*(SX[y+1] - SX[j])
                 - yj*(SY[y+1] - SY[j])
                 )%mod
            continue
        while y-x>1:
            mid = (y+x)//2
            if is_ok(xy[mid]):
                x = mid
            else:
                y = mid
        S = (S 
                + xj*(SX[x+1] - SX[j])
                - yj*(SY[x+1] - SY[j])
                )%mod        


            
print(S)
0