結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 140 ms
29,728 KB
testcase_02 AC 139 ms
29,712 KB
testcase_03 AC 142 ms
29,732 KB
testcase_04 AC 140 ms
30,108 KB
testcase_05 AC 272 ms
99,376 KB
testcase_06 AC 223 ms
72,280 KB
testcase_07 AC 233 ms
77,984 KB
testcase_08 AC 203 ms
63,192 KB
testcase_09 AC 141 ms
29,852 KB
testcase_10 AC 164 ms
40,840 KB
testcase_11 AC 244 ms
84,152 KB
testcase_12 AC 187 ms
54,440 KB
testcase_13 AC 292 ms
112,332 KB
testcase_14 AC 291 ms
112,536 KB
testcase_15 AC 295 ms
111,544 KB
testcase_16 AC 223 ms
112,856 KB
testcase_17 AC 220 ms
111,728 KB
testcase_18 AC 282 ms
112,436 KB
testcase_19 AC 284 ms
112,896 KB
testcase_20 AC 289 ms
110,408 KB
testcase_21 AC 293 ms
113,260 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 146 ms
30,460 KB
testcase_26 AC 146 ms
30,404 KB
testcase_27 AC 144 ms
30,440 KB
testcase_28 AC 143 ms
30,404 KB
testcase_29 AC 177 ms
47,912 KB
testcase_30 AC 160 ms
38,608 KB
testcase_31 AC 208 ms
63,976 KB
testcase_32 AC 225 ms
75,316 KB
testcase_33 AC 144 ms
30,488 KB
testcase_34 AC 146 ms
30,536 KB
testcase_35 AC 145 ms
30,492 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-16

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