結果

問題 No.947 ABC包囲網
ユーザー tamatotamato
提出日時 2019-12-10 18:29:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 77,524 KB
最終ジャッジ日時 2023-09-06 07:21:51
合計ジャッジ時間 8,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,896 KB
testcase_01 AC 73 ms
71,584 KB
testcase_02 AC 72 ms
71,672 KB
testcase_03 AC 73 ms
71,824 KB
testcase_04 WA -
testcase_05 AC 72 ms
71,552 KB
testcase_06 AC 71 ms
71,644 KB
testcase_07 AC 72 ms
71,828 KB
testcase_08 AC 73 ms
71,336 KB
testcase_09 AC 73 ms
71,436 KB
testcase_10 AC 76 ms
71,020 KB
testcase_11 AC 76 ms
71,672 KB
testcase_12 AC 73 ms
71,580 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 74 ms
71,868 KB
testcase_16 AC 75 ms
71,840 KB
testcase_17 AC 72 ms
71,644 KB
testcase_18 AC 74 ms
71,460 KB
testcase_19 AC 74 ms
71,572 KB
testcase_20 AC 75 ms
71,624 KB
testcase_21 AC 74 ms
71,848 KB
testcase_22 AC 77 ms
71,924 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 105 ms
76,896 KB
testcase_29 AC 98 ms
77,264 KB
testcase_30 AC 94 ms
77,344 KB
testcase_31 AC 100 ms
77,168 KB
testcase_32 AC 102 ms
77,388 KB
testcase_33 AC 103 ms
77,392 KB
testcase_34 AC 99 ms
77,356 KB
testcase_35 AC 100 ms
77,524 KB
testcase_36 AC 103 ms
77,208 KB
testcase_37 AC 103 ms
77,308 KB
testcase_38 AC 99 ms
77,396 KB
testcase_39 AC 104 ms
77,484 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 100 ms
77,480 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 103 ms
77,276 KB
testcase_50 WA -
testcase_51 AC 73 ms
71,680 KB
testcase_52 AC 71 ms
71,664 KB
testcase_53 AC 74 ms
71,804 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 75 ms
71,648 KB
testcase_57 AC 75 ms
71,592 KB
testcase_58 AC 78 ms
71,648 KB
testcase_59 AC 76 ms
71,552 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

print(ans)
0