結果
| 問題 |
No.1144 Triangles
|
| コンテスト | |
| ユーザー |
hotman78
|
| 提出日時 | 2020-07-24 16:43:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 923 bytes |
| コンパイル時間 | 290 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 135,212 KB |
| 最終ジャッジ日時 | 2024-07-05 06:33:15 |
| 合計ジャッジ時間 | 4,980 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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