結果

問題 No.1490 スライムと爆弾
ユーザー H3PO4H3PO4
提出日時 2022-08-02 21:36:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,258 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 132,496 KB
最終ジャッジ日時 2023-09-30 21:47:53
合計ジャッジ時間 15,250 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
29,672 KB
testcase_01 AC 128 ms
29,632 KB
testcase_02 AC 130 ms
29,868 KB
testcase_03 AC 129 ms
29,760 KB
testcase_04 AC 127 ms
29,780 KB
testcase_05 AC 127 ms
29,760 KB
testcase_06 AC 130 ms
29,776 KB
testcase_07 AC 129 ms
29,656 KB
testcase_08 AC 127 ms
29,748 KB
testcase_09 AC 127 ms
29,708 KB
testcase_10 AC 127 ms
29,760 KB
testcase_11 AC 127 ms
29,576 KB
testcase_12 AC 126 ms
29,740 KB
testcase_13 AC 669 ms
77,244 KB
testcase_14 AC 589 ms
86,728 KB
testcase_15 AC 469 ms
70,380 KB
testcase_16 AC 521 ms
65,496 KB
testcase_17 AC 348 ms
71,844 KB
testcase_18 AC 623 ms
87,056 KB
testcase_19 AC 600 ms
81,472 KB
testcase_20 AC 533 ms
70,516 KB
testcase_21 AC 368 ms
62,840 KB
testcase_22 AC 575 ms
71,044 KB
testcase_23 AC 129 ms
29,720 KB
testcase_24 AC 127 ms
29,592 KB
testcase_25 AC 639 ms
115,608 KB
testcase_26 AC 637 ms
115,652 KB
testcase_27 AC 642 ms
115,524 KB
testcase_28 AC 882 ms
109,464 KB
testcase_29 AC 892 ms
109,156 KB
testcase_30 AC 1,258 ms
132,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

import numpy as np

input = sys.stdin.buffer.readline

H, W, N, M = map(int, input().split())
slimes = tuple(tuple(map(int, input().split())) for _ in range(N))
bombs = tuple(tuple(map(int, input().split())) for _ in range(M))

table = np.zeros((H + 2, W + 2), dtype=np.int64)
for x, y, b, c in bombs:
    x -= 1
    y -= 1
    u = max(x - b, 0) + 1
    d = min(x + b + 1, H) + 1
    l = max(y - b, 0) + 1
    r = min(y + b + 1, W) + 1
    table[u, l] += c
    table[u, r] -= c
    table[d, l] -= c
    table[d, r] += c

# 各マスの爆風を計算するimos
table = table.cumsum(axis=0)
table = table.cumsum(axis=1)

# スライム用のimos
table = table.cumsum(axis=0)
table = table.cumsum(axis=1)

ans = 0
for t, u, l, r, a in slimes:
    t -= 1
    l -= 1
    if table[t, l] - table[t, r] - table[u, l] + table[u, r] < a:
        ans += 1
print(ans)
0