結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2019-12-10 02:17:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 747 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 97,396 KB |
| 最終ジャッジ日時 | 2024-06-23 13:02:51 |
| 合計ジャッジ時間 | 13,253 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 TLE * 2 -- * 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)]
Q=[]
for x,y in P:
if x>0:
Q.append((1,Fraction(y,x)))
elif x==0:
if y>0:
Q.append((1,float("inf")))
else:
Q.append((0,float("inf")))
else:
Q.append((0,Fraction(y,x)))
#print(Q)
Q.sort()
ANS=0
import bisect
for i in range(n-1):
for j in range(i+1,n):
if Q[i][0]==Q[j][0]:
x=bisect.bisect_right(Q,(1-Q[i][0],Q[i][1]))
y=bisect.bisect_left(Q,(1-Q[j][0],Q[j][1]))
#print(i,j,x,y)
ANS+=max(0,y-x)
else:
continue
print(ANS)
titia