結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー tamatotamato
提出日時 2023-02-24 21:50:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 77,500 KB
最終ジャッジ日時 2023-10-11 06:08:31
合計ジャッジ時間 6,174 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,192 KB
testcase_01 AC 77 ms
71,056 KB
testcase_02 AC 76 ms
71,040 KB
testcase_03 AC 76 ms
71,320 KB
testcase_04 AC 75 ms
71,280 KB
testcase_05 AC 74 ms
71,316 KB
testcase_06 AC 77 ms
71,476 KB
testcase_07 AC 132 ms
76,700 KB
testcase_08 AC 139 ms
77,096 KB
testcase_09 AC 147 ms
77,008 KB
testcase_10 AC 130 ms
76,696 KB
testcase_11 AC 131 ms
76,924 KB
testcase_12 AC 114 ms
76,836 KB
testcase_13 AC 116 ms
77,004 KB
testcase_14 AC 113 ms
76,852 KB
testcase_15 AC 159 ms
77,308 KB
testcase_16 AC 159 ms
77,184 KB
testcase_17 AC 159 ms
77,328 KB
testcase_18 AC 159 ms
76,876 KB
testcase_19 AC 162 ms
76,824 KB
testcase_20 AC 161 ms
76,820 KB
testcase_21 AC 159 ms
77,116 KB
testcase_22 AC 159 ms
77,060 KB
testcase_23 AC 125 ms
77,500 KB
testcase_24 AC 127 ms
77,000 KB
testcase_25 AC 128 ms
76,968 KB
testcase_26 AC 111 ms
77,180 KB
testcase_27 AC 98 ms
77,168 KB
testcase_28 AC 147 ms
76,900 KB
testcase_29 AC 145 ms
77,440 KB
testcase_30 AC 102 ms
77,092 KB
testcase_31 AC 109 ms
77,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    def f(h):
        h += 1
        return h * (h + 1) // 2

    H, W, K = map(int, input().split())
    ans = 0
    for _ in range(K):
        h, w, v = map(int, input().split())
        h -= 1
        w -= 1
        tmp = ((h + 1) * (h + 1)) % mod
        h1 = h - w - 1
        if h1 >= 0:
            tmp = (tmp - f(h1)) % mod
        h2 = h - (W - w)
        if h2 >= 0:
            tmp = (tmp - f(h2)) % mod
        ans = (ans + tmp * v) % mod
    print(ans)


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