結果

問題 No.1144 Triangles
ユーザー hotman78hotman78
提出日時 2020-07-24 16:43:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 923 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 13,944 KB
最終ジャッジ日時 2023-09-18 16:05:58
合計ジャッジ時間 5,453 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
13,148 KB
testcase_01 AC 20 ms
8,696 KB
testcase_02 AC 20 ms
8,820 KB
testcase_03 AC 21 ms
8,644 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