結果

問題 No.947 ABC包囲網
ユーザー maspymaspy
提出日時 2020-03-21 20:21:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 30,532 KB
最終ジャッジ日時 2023-08-25 01:15:54
合計ジャッジ時間 17,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
29,816 KB
testcase_01 AC 131 ms
29,804 KB
testcase_02 AC 127 ms
29,804 KB
testcase_03 AC 129 ms
29,880 KB
testcase_04 AC 127 ms
29,876 KB
testcase_05 AC 129 ms
29,860 KB
testcase_06 AC 132 ms
29,836 KB
testcase_07 AC 133 ms
29,880 KB
testcase_08 WA -
testcase_09 AC 127 ms
29,836 KB
testcase_10 AC 129 ms
29,900 KB
testcase_11 AC 129 ms
29,832 KB
testcase_12 AC 128 ms
29,928 KB
testcase_13 AC 134 ms
29,876 KB
testcase_14 AC 132 ms
29,924 KB
testcase_15 WA -
testcase_16 AC 133 ms
29,836 KB
testcase_17 AC 132 ms
29,844 KB
testcase_18 AC 134 ms
29,888 KB
testcase_19 AC 134 ms
29,768 KB
testcase_20 AC 136 ms
29,824 KB
testcase_21 AC 133 ms
29,844 KB
testcase_22 AC 132 ms
29,948 KB
testcase_23 AC 132 ms
29,696 KB
testcase_24 AC 132 ms
29,880 KB
testcase_25 AC 132 ms
29,800 KB
testcase_26 AC 135 ms
29,820 KB
testcase_27 AC 131 ms
29,816 KB
testcase_28 AC 241 ms
30,520 KB
testcase_29 AC 237 ms
30,368 KB
testcase_30 AC 240 ms
30,444 KB
testcase_31 AC 245 ms
30,516 KB
testcase_32 AC 241 ms
30,360 KB
testcase_33 AC 243 ms
30,496 KB
testcase_34 AC 245 ms
30,368 KB
testcase_35 AC 241 ms
30,360 KB
testcase_36 AC 243 ms
30,528 KB
testcase_37 AC 243 ms
30,404 KB
testcase_38 AC 242 ms
30,528 KB
testcase_39 AC 237 ms
30,336 KB
testcase_40 AC 241 ms
30,532 KB
testcase_41 WA -
testcase_42 AC 242 ms
30,520 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 238 ms
30,420 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 241 ms
30,348 KB
testcase_49 AC 244 ms
30,496 KB
testcase_50 WA -
testcase_51 AC 130 ms
29,916 KB
testcase_52 AC 128 ms
29,764 KB
testcase_53 AC 131 ms
29,800 KB
testcase_54 AC 126 ms
29,808 KB
testcase_55 AC 129 ms
29,756 KB
testcase_56 AC 129 ms
29,900 KB
testcase_57 AC 132 ms
29,748 KB
testcase_58 AC 136 ms
29,808 KB
testcase_59 AC 132 ms
29,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
XY = np.array(read().split(), np.int64)
X = XY[::2]
Y = XY[1::2]
g = np.abs(np.gcd(X, Y))
Xd = X // g
Yd = Y // g
key = (Xd << 32) + Yd

total = N * (N - 1) * (N - 2) // 6
ng0 = 0
ng1 = 0
ng2 = 0
ng3 = 0
for x, y, k in zip(X, Y, key):
    n = np.count_nonzero(X * y - Y * x > 0)
    same = np.count_nonzero(key == k)
    opp = np.count_nonzero(key == -k)
    ng0 += n * (n - 1) // 2
    ng1 += (same - 1) * n
    ng2 += opp * (N - same - opp)
    ng3 += (same - 1) * opp

ng = ng0 + (ng1 + ng2 + ng3) // 2

print(total - ng)
0