結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー ああいい
提出日時 2023-02-25 16:38:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 76,760 KB
最終ジャッジ日時 2024-09-13 13:00:25
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W,K = map(int,input().split())
P = 998244353

def calc(x,y):
    ans = 0
    if x >= y:
        ans += (y * y + y) // 2
        ans += y * (x - y)
    else:
        ans += (x * x + x) // 2
    return ans
ans = 0
for _ in range(K):
    x,y,v = map(int,input().split())
    tmp = 0
    tmp += calc(x,y) + calc(x,W - y + 1) - x
    ans += tmp * v % P
    ans %= P
print(ans)
0