結果

問題 No.947 ABC包囲網
ユーザー tamatotamato
提出日時 2019-12-10 18:32:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,359 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 70,016 KB
最終ジャッジ日時 2024-06-24 02:04:51
合計ジャッジ時間 5,133 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,992 KB
testcase_01 AC 44 ms
52,608 KB
testcase_02 AC 45 ms
52,736 KB
testcase_03 AC 43 ms
52,608 KB
testcase_04 WA -
testcase_05 AC 42 ms
52,480 KB
testcase_06 AC 43 ms
52,844 KB
testcase_07 AC 44 ms
52,864 KB
testcase_08 AC 42 ms
52,480 KB
testcase_09 AC 42 ms
52,352 KB
testcase_10 AC 42 ms
52,480 KB
testcase_11 AC 42 ms
52,864 KB
testcase_12 AC 42 ms
52,352 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 42 ms
53,504 KB
testcase_16 AC 43 ms
53,120 KB
testcase_17 AC 43 ms
53,120 KB
testcase_18 AC 44 ms
52,864 KB
testcase_19 AC 43 ms
53,248 KB
testcase_20 AC 44 ms
53,248 KB
testcase_21 AC 44 ms
52,864 KB
testcase_22 AC 44 ms
53,504 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 62 ms
65,236 KB
testcase_29 AC 67 ms
67,200 KB
testcase_30 AC 64 ms
66,688 KB
testcase_31 AC 74 ms
69,760 KB
testcase_32 AC 76 ms
69,504 KB
testcase_33 AC 73 ms
70,016 KB
testcase_34 AC 75 ms
69,248 KB
testcase_35 AC 74 ms
69,632 KB
testcase_36 AC 76 ms
69,760 KB
testcase_37 AC 77 ms
69,760 KB
testcase_38 AC 75 ms
69,760 KB
testcase_39 AC 74 ms
69,888 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 75 ms
69,888 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 75 ms
69,760 KB
testcase_50 WA -
testcase_51 AC 42 ms
53,120 KB
testcase_52 AC 43 ms
53,120 KB
testcase_53 AC 43 ms
52,864 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 41 ms
52,736 KB
testcase_57 AC 44 ms
53,376 KB
testcase_58 AC 43 ms
53,376 KB
testcase_59 AC 44 ms
53,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import atan, pi
import sys
input = sys.stdin.buffer.readline


def atan_(val):
    ret = atan(val)
    if ret >= 0:
        return ret
    else:
        return ret + pi


N = int(input())
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))

P = []
n_pos = 0
for x, y in points:
    if y > 0:
        n_pos += 1
        if x == 0:
            P.append((pi, 1))
        else:
            P.append((atan_(y / x), 1))
    elif y < 0:
        if x == 0:
            P.append((pi, -1))
        else:
            P.append((atan_(y / x), -1))
    else:
        if x > 0:
            n_pos += 1
            P.append((0, 1))
        else:
            P.append((0, -1))
n_neg = N - n_pos

P.sort(key=lambda p: p[0])
pos = 0
neg = 0
prev = -1
tmp_pos = 0
tmp_neg = 0
ans = 0
for rad, pn in P:
    if rad != prev:
        ans += tmp_pos * neg * (n_neg - neg - tmp_neg)
        ans += tmp_neg * pos * (n_pos - pos - tmp_pos)
        pos += tmp_pos
        neg += tmp_neg
        prev = rad
        if pn == 1:
            tmp_pos = 1
            tmp_neg = 0
        else:
            tmp_pos = 0
            tmp_neg = 1
    else:
        if pn == 1:
            tmp_pos += 1
        else:
            tmp_neg += 1

ans += tmp_pos * neg * (n_neg - neg - tmp_neg)
ans += tmp_neg * pos * (n_pos - pos - tmp_pos)

print(ans)
0