結果

問題 No.461 三角形はいくつ?
ユーザー maspymaspy
提出日時 2020-04-08 16:07:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 114,248 KB
最終ジャッジ日時 2023-09-25 18:24:52
合計ジャッジ時間 12,670 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,956 KB
testcase_01 AC 137 ms
29,924 KB
testcase_02 AC 139 ms
29,928 KB
testcase_03 AC 136 ms
29,880 KB
testcase_04 AC 140 ms
30,152 KB
testcase_05 AC 270 ms
99,604 KB
testcase_06 AC 214 ms
72,300 KB
testcase_07 AC 227 ms
78,224 KB
testcase_08 AC 198 ms
63,536 KB
testcase_09 AC 136 ms
30,068 KB
testcase_10 AC 160 ms
40,920 KB
testcase_11 AC 239 ms
84,392 KB
testcase_12 AC 183 ms
54,268 KB
testcase_13 AC 307 ms
112,480 KB
testcase_14 AC 291 ms
112,392 KB
testcase_15 AC 294 ms
111,872 KB
testcase_16 AC 217 ms
112,944 KB
testcase_17 AC 221 ms
112,076 KB
testcase_18 AC 286 ms
112,628 KB
testcase_19 AC 285 ms
113,244 KB
testcase_20 AC 283 ms
110,760 KB
testcase_21 AC 281 ms
113,192 KB
testcase_22 AC 285 ms
113,104 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 139 ms
30,668 KB
testcase_26 AC 138 ms
30,748 KB
testcase_27 AC 138 ms
30,636 KB
testcase_28 AC 138 ms
30,712 KB
testcase_29 AC 174 ms
48,032 KB
testcase_30 AC 157 ms
38,736 KB
testcase_31 AC 197 ms
64,168 KB
testcase_32 AC 218 ms
75,164 KB
testcase_33 AC 138 ms
30,620 KB
testcase_34 AC 142 ms
30,760 KB
testcase_35 AC 140 ms
30,740 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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

eps = 1e-12

N = int(readline())
X = [[0] for _ in range(3)]
m = map(int, read().split())
for p, a, b in zip(m, m, m):
    x = b / (a + b)
    X[p].append(x)

X.sort(key=len)


def solve_naive():
    import itertools
    ret = 0
    for x1, x2, x3 in itertools.product(*X):
        if 1 - eps < x1 + x2 + x3 < 1 + eps:
            continue
        if x1 + x3 > 1 + eps:
            continue
        if x1 + x2 > 1 + eps:
            continue
        if x2 + x3 > 1 + eps:
            continue
        ret += 1
    return ret


def solve(X, Y, Z):
    X.sort()
    Y.sort()
    Z.sort()
    add_XY = np.add.outer(X, Y).ravel()
    max_XY = np.maximum.outer(X, Y).ravel()
    cnt_Z = np.searchsorted(Z, 1 - max_XY + eps)
    ret = (cnt_Z * (add_XY < 1 + eps)).sum()
    # 1点で交わるものを除く
    ret -= (np.searchsorted(Z, 1 - add_XY + eps) - np.searchsorted(Z, 1 - add_XY - eps)).sum()
    return ret


X, Y, Z = map(np.array, X)

print(solve(X, Y, Z))
0