結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2021-03-18 18:50:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,910 bytes |
| コンパイル時間 | 788 ms |
| コンパイル使用メモリ | 82,328 KB |
| 実行使用メモリ | 158,592 KB |
| 最終ジャッジ日時 | 2024-11-16 22:04:59 |
| 合計ジャッジ時間 | 75,887 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 TLE * 23 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7
class v:
def __init__(self, x, y):
self.x = x
self.y = y
def zone(self, v):
x = v.x
y = v.y
if x > 0 and y >= 0: return 1
if x <= 0 and y > 0: return 2
if x < 0 and y <= 0: return 3
return 4
def rev(self):
return v(-self.x, -self.y)
def __mul__(self, other):
return self.x*other.y-self.y*other.x
def __eq__(self, other):
return self*other == 0 and self.zone(self) == self.zone(other)
def __lt__(self, other):
z1 = self.zone(self)
z2 = self.zone(other)
if z1 < z2: return True
if z1 > z2: return False
return self*other > 0
def __repr__(self):
return f"({self.x},{self.y})"
from bisect import *
n = II()
vv = []
for _ in range(n):
x, y = LI()
vv.append(v(x, y))
vv.sort()
# print(vv)
ans = 0
for j in range(n):
for i in range(j):
v1 = vv[i].rev()
v2 = vv[j].rev()
if v1*v2 == 0: continue
if v1*v2 < 0: v1, v2 = v2, v1
l = bisect_right(vv, v1)
r = bisect_left(vv, v2)
if l <= r: ans += r-l
else: ans += n-l+r
# print(v1, v2, l, r, ans)
print(ans//3)
mkawa2