結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-12-09 00:50:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 76,972 KB
最終ジャッジ日時 2024-04-22 18:50:11
合計ジャッジ時間 7,013 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,840 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 41 ms
51,968 KB
testcase_03 AC 36 ms
52,352 KB
testcase_04 AC 34 ms
52,224 KB
testcase_05 AC 35 ms
51,968 KB
testcase_06 AC 35 ms
52,096 KB
testcase_07 AC 175 ms
76,544 KB
testcase_08 AC 184 ms
76,544 KB
testcase_09 AC 175 ms
76,160 KB
testcase_10 AC 177 ms
76,800 KB
testcase_11 AC 189 ms
76,544 KB
testcase_12 AC 120 ms
76,024 KB
testcase_13 AC 120 ms
76,416 KB
testcase_14 AC 117 ms
76,392 KB
testcase_15 AC 179 ms
76,972 KB
testcase_16 AC 181 ms
75,968 KB
testcase_17 AC 180 ms
76,288 KB
testcase_18 AC 177 ms
76,640 KB
testcase_19 AC 178 ms
76,356 KB
testcase_20 AC 176 ms
76,208 KB
testcase_21 AC 180 ms
76,288 KB
testcase_22 AC 198 ms
76,392 KB
testcase_23 AC 126 ms
75,992 KB
testcase_24 AC 127 ms
76,160 KB
testcase_25 AC 135 ms
76,428 KB
testcase_26 AC 107 ms
76,288 KB
testcase_27 AC 91 ms
76,544 KB
testcase_28 AC 168 ms
76,288 KB
testcase_29 AC 155 ms
76,416 KB
testcase_30 AC 85 ms
76,160 KB
testcase_31 AC 98 ms
75,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W, K = map(int, input().split())
ans = 0
mod = 998244353

def calc(x, y):
    ret = 0
    if x <= y:
        ret += x * (x + 1) // 2
    else:
        ret += (x * (x + 1) // 2 - (x - y) * (x - y + 1) // 2)

    if x <= W - y + 1:
        ret += x * (x + 1) // 2
    else:
        ret += (x * (x + 1) // 2 - (x - (W - y + 1)) * (x - (W - y + 1) + 1) // 2)
    ret -= x
    return ret

for i in range(K):
    x, y, v = map(int, input().split())
    C = calc(x, y) % mod
    ans = (ans + C * v) % mod
print(ans)
0