結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2019-12-10 02:24:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 737 bytes |
| コンパイル時間 | 327 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 95,872 KB |
| 最終ジャッジ日時 | 2024-06-23 13:10:32 |
| 合計ジャッジ時間 | 10,140 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 TLE * 1 -- * 30 |
ソースコード
from fractions import Fraction
import sys
input = sys.stdin.readline
n=int(input())
P=[tuple(map(int,input().split())) for i in range(n)]
Q0=[]
Q1=[]
for x,y in P:
if x>0:
Q1.append(Fraction(y,x))
elif x==0:
if y>0:
Q1.append(float("inf"))
else:
Q0.append(float("inf"))
else:
Q0.append(Fraction(y,x))
Q0.sort()
Q1.sort()
ANS=0
import bisect
for i in range(len(Q0)-1):
for j in range(i+1,len(Q0)):
ANS+=max(0,bisect.bisect_left(Q1,Q0[j])-bisect.bisect_right(Q1,Q0[i]))
for i in range(len(Q1)-1):
for j in range(i+1,len(Q1)):
ANS+=max(0,bisect.bisect_left(Q0,Q1[j])-bisect.bisect_right(Q0,Q1[i]))
print(ANS)
titia