結果

問題 No.947 ABC包囲網
ユーザー maspymaspy
提出日時 2020-03-21 20:23:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 30,480 KB
最終ジャッジ日時 2023-08-25 01:19:36
合計ジャッジ時間 14,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
29,696 KB
testcase_01 AC 126 ms
29,876 KB
testcase_02 AC 125 ms
29,708 KB
testcase_03 AC 127 ms
29,764 KB
testcase_04 AC 125 ms
29,748 KB
testcase_05 AC 125 ms
29,700 KB
testcase_06 AC 125 ms
29,716 KB
testcase_07 AC 125 ms
29,760 KB
testcase_08 AC 124 ms
29,784 KB
testcase_09 AC 124 ms
29,776 KB
testcase_10 AC 124 ms
29,924 KB
testcase_11 AC 127 ms
29,752 KB
testcase_12 AC 125 ms
29,892 KB
testcase_13 AC 124 ms
29,800 KB
testcase_14 AC 125 ms
29,912 KB
testcase_15 AC 130 ms
29,632 KB
testcase_16 AC 127 ms
29,772 KB
testcase_17 AC 126 ms
29,752 KB
testcase_18 AC 126 ms
29,892 KB
testcase_19 AC 127 ms
29,752 KB
testcase_20 AC 126 ms
29,696 KB
testcase_21 AC 127 ms
29,840 KB
testcase_22 AC 125 ms
29,876 KB
testcase_23 AC 126 ms
29,792 KB
testcase_24 AC 126 ms
29,804 KB
testcase_25 AC 126 ms
29,784 KB
testcase_26 AC 131 ms
29,808 KB
testcase_27 AC 131 ms
29,936 KB
testcase_28 AC 239 ms
30,436 KB
testcase_29 AC 235 ms
30,260 KB
testcase_30 AC 237 ms
30,376 KB
testcase_31 AC 239 ms
30,320 KB
testcase_32 AC 239 ms
30,400 KB
testcase_33 AC 244 ms
30,416 KB
testcase_34 AC 244 ms
30,340 KB
testcase_35 AC 241 ms
30,292 KB
testcase_36 AC 243 ms
30,352 KB
testcase_37 AC 246 ms
30,376 KB
testcase_38 AC 241 ms
30,372 KB
testcase_39 AC 243 ms
30,320 KB
testcase_40 AC 243 ms
30,444 KB
testcase_41 AC 246 ms
30,324 KB
testcase_42 AC 247 ms
30,396 KB
testcase_43 AC 243 ms
30,284 KB
testcase_44 AC 243 ms
30,476 KB
testcase_45 AC 240 ms
30,480 KB
testcase_46 AC 240 ms
30,320 KB
testcase_47 AC 247 ms
30,372 KB
testcase_48 AC 248 ms
30,380 KB
testcase_49 AC 243 ms
30,320 KB
testcase_50 AC 242 ms
30,432 KB
testcase_51 AC 132 ms
29,864 KB
testcase_52 AC 131 ms
29,816 KB
testcase_53 AC 134 ms
29,664 KB
testcase_54 AC 127 ms
29,840 KB
testcase_55 AC 128 ms
29,760 KB
testcase_56 AC 129 ms
29,760 KB
testcase_57 AC 137 ms
29,752 KB
testcase_58 AC 138 ms
29,800 KB
testcase_59 AC 132 ms
29,756 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
ng4 = 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
    ng4 += (same - 1) * (same - 2) // 2

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

print(total - ng)
0