結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
29,892 KB
testcase_01 AC 136 ms
30,024 KB
testcase_02 AC 140 ms
29,908 KB
testcase_03 AC 139 ms
29,980 KB
testcase_04 AC 139 ms
30,144 KB
testcase_05 AC 291 ms
99,656 KB
testcase_06 AC 214 ms
72,232 KB
testcase_07 AC 228 ms
78,132 KB
testcase_08 AC 203 ms
63,460 KB
testcase_09 AC 141 ms
30,064 KB
testcase_10 AC 167 ms
40,948 KB
testcase_11 AC 239 ms
84,412 KB
testcase_12 AC 188 ms
54,332 KB
testcase_13 AC 287 ms
112,416 KB
testcase_14 AC 285 ms
112,524 KB
testcase_15 AC 290 ms
111,628 KB
testcase_16 AC 220 ms
112,992 KB
testcase_17 AC 215 ms
111,920 KB
testcase_18 AC 281 ms
112,696 KB
testcase_19 AC 283 ms
113,212 KB
testcase_20 AC 288 ms
110,820 KB
testcase_21 AC 291 ms
113,480 KB
testcase_22 AC 288 ms
113,056 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 144 ms
30,732 KB
testcase_26 AC 142 ms
30,612 KB
testcase_27 AC 143 ms
30,672 KB
testcase_28 AC 143 ms
30,744 KB
testcase_29 AC 175 ms
48,036 KB
testcase_30 AC 157 ms
38,784 KB
testcase_31 AC 199 ms
64,128 KB
testcase_32 AC 219 ms
75,096 KB
testcase_33 AC 143 ms
30,764 KB
testcase_34 AC 143 ms
30,732 KB
testcase_35 AC 142 ms
30,820 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-11

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