結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー hari64hari64
提出日時 2022-12-19 21:10:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 923 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,776 KB
最終ジャッジ日時 2024-04-29 02:31:21
合計ジャッジ時間 18,616 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,624 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 34 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 32 ms
10,496 KB
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 817 ms
37,376 KB
testcase_08 AC 923 ms
43,648 KB
testcase_09 AC 840 ms
36,480 KB
testcase_10 AC 816 ms
37,376 KB
testcase_11 AC 818 ms
37,376 KB
testcase_12 AC 461 ms
27,136 KB
testcase_13 AC 456 ms
27,136 KB
testcase_14 AC 447 ms
27,008 KB
testcase_15 AC 896 ms
43,648 KB
testcase_16 AC 885 ms
43,520 KB
testcase_17 AC 909 ms
43,520 KB
testcase_18 AC 896 ms
43,520 KB
testcase_19 AC 897 ms
43,648 KB
testcase_20 AC 897 ms
43,776 KB
testcase_21 AC 895 ms
43,648 KB
testcase_22 AC 888 ms
43,776 KB
testcase_23 AC 377 ms
23,552 KB
testcase_24 AC 463 ms
27,648 KB
testcase_25 AC 531 ms
30,336 KB
testcase_26 AC 227 ms
18,432 KB
testcase_27 AC 96 ms
13,056 KB
testcase_28 AC 759 ms
38,016 KB
testcase_29 AC 703 ms
35,968 KB
testcase_30 AC 123 ms
14,336 KB
testcase_31 AC 213 ms
17,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def rectangle(len):
    return 0 if len < 0 else ((len)*(len+1)//2)


def inverted(W, I, J, V):
    cnt = (I+1)*(I+1)-rectangle(I-J)-rectangle(I+J+1-W)
    return V * cnt % 998244353


def main():
    H, W, K = map(int, input().split())
    assert(1 <= H and H <= 100000)
    assert(1 <= W and W <= 100000)
    assert(0 <= K and K <= min(H*W, 200000))

    XYVs = [None for _ in range(K)]
    for i in range(K):
        X, Y, V = map(int, input().split())
        assert(1 <= X and X <= H)
        assert(1 <= Y and Y <= W)
        assert(0 <= V and V <= 1000000000)
        X -= 1
        Y -= 1
        XYVs[i] = (X, Y, V)

    ans = 0
    for x, y, v in XYVs:
        ans += inverted(W, x, y, v)
    print(ans % 998244353)


if __name__ == '__main__':
    main()
0