結果
| 問題 | 
                            No.1144 Triangles
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hotman78
                         | 
                    
| 提出日時 | 2020-07-24 16:43:35 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 923 bytes | 
| コンパイル時間 | 130 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 18,336 KB | 
| 最終ジャッジ日時 | 2024-07-05 06:32:56 | 
| 合計ジャッジ時間 | 5,026 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | TLE * 1 -- * 24 | 
ソースコード
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)
            
            
            
        
            
hotman78