結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2019-12-10 02:25:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 737 bytes |
| コンパイル時間 | 94 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 19,360 KB |
| 最終ジャッジ日時 | 2024-06-23 13:12:40 |
| 合計ジャッジ時間 | 7,465 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 TLE * 1 -- * 31 |
ソースコード
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