結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー lloyzlloyz
提出日時 2024-01-02 14:30:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 76,644 KB
最終ジャッジ日時 2024-01-02 14:30:14
合計ジャッジ時間 8,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 47 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 190 ms
76,260 KB
testcase_08 AC 198 ms
76,156 KB
testcase_09 AC 185 ms
75,884 KB
testcase_10 AC 188 ms
76,260 KB
testcase_11 AC 213 ms
76,644 KB
testcase_12 AC 168 ms
76,140 KB
testcase_13 AC 124 ms
75,764 KB
testcase_14 AC 140 ms
76,140 KB
testcase_15 AC 186 ms
75,788 KB
testcase_16 AC 185 ms
75,784 KB
testcase_17 AC 186 ms
75,784 KB
testcase_18 AC 185 ms
75,788 KB
testcase_19 AC 196 ms
75,788 KB
testcase_20 AC 185 ms
75,788 KB
testcase_21 AC 185 ms
75,784 KB
testcase_22 AC 186 ms
75,792 KB
testcase_23 AC 117 ms
75,916 KB
testcase_24 AC 125 ms
75,784 KB
testcase_25 AC 134 ms
75,776 KB
testcase_26 AC 101 ms
75,792 KB
testcase_27 AC 83 ms
75,788 KB
testcase_28 AC 165 ms
75,776 KB
testcase_29 AC 162 ms
75,792 KB
testcase_30 AC 82 ms
75,780 KB
testcase_31 AC 95 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w, k = map(int, input().split())
mod = 998244353
ans = 0
inv2 = pow(2, mod - 2, mod)
for _ in range(k):
    x, y, v = map(int, input().split())
    cnt = pow(x, 2, mod)
    if y < x:
        d = x - y
        cnt -= d * (d + 1) % mod * inv2 % mod
        cnt %= mod
    if (w - y) < x - 1:
        d = x - (w - y) - 1
        cnt -= d * (d + 1) % mod * inv2 % mod
        cnt %= mod
    ans += v * cnt % mod
    ans %= mod
print(ans)
0