結果

問題 No.1144 Triangles
ユーザー hotman78hotman78
提出日時 2020-07-24 16:46:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 923 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 127,216 KB
最終ジャッジ日時 2023-09-18 16:06:48
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
76,520 KB
testcase_01 AC 109 ms
72,132 KB
testcase_02 AC 104 ms
72,216 KB
testcase_03 AC 107 ms
76,040 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cmp_to_key

n=int(input())
a=[]
for i in range(n):
    x,y=map(int, input().split())
    a.append((x,y))
def pos(v):
    if v[1]<0:
        return -1
    if v[1]==0 and 0<=v[0]:
        return 0
    return 1

def comp(s,t):
    if(pos(s)!=pos(t)):
        return -1 if pos(s)<pos(t) else 1
    return -1 if 0<s[0]*t[1]-s[1]*t[0] else 1
ans=0
for x1,y1 in a:
    q=[]
    for x2,y2 in a:
        if x1==x2 and y1==y2:
            continue
        q.append((x2-x1,y2-y1))
    
    q.sort(key=cmp_to_key(comp))
    l=0
    r=0
    while(l+len(q)!=0 and q[0][0]*q[l%len(q)][1]-q[0][1]*q[l%len(q)][0]==0):
        l=l-1
    for j in range(len(q)):
        if(j!=0 and q[j][0]*q[j-1][1]-q[j][1]*q[j-1][0]!=0):
            l=j-1
        while(r!=j+len(q) and q[j][0]*q[r%len(q)][1]-q[j][1]*q[r%len(q)][0]>=0):
           r=r+1
        ans=(ans+(r-l)*(x1*(y1+q[j][1])-y1*(x1+q[j][0]))) %1000000007 
print(ans)
0