結果

問題 No.2229 Treasure Searching Rod (Hard)
コンテスト
ユーザー 👑 Kazun
提出日時 2023-02-24 22:11:19
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 121 ms / 2,000 ms
+ 264µs
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 241 ms
コンパイル使用メモリ 95,260 KB
実行使用メモリ 84,352 KB
最終ジャッジ日時 2026-08-25 23:12:16
合計ジャッジ時間 6,223 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def f(a,b):
    if a>b:
        return 0
    n=b-a+1
    return (n*(b+a))//2

def solve():
    H,W,K=map(int,input().split())

    Ans=0; Mod=998244353
    for k in range(K):
        x,y,v=map(int,input().split())

        p=y-1; q=W-y
        area=x*W-(f(max(1,p-(x-1)),p)+f(max(1,q-(x-1)),q))%Mod
        Ans+=area*v%Mod

    return Ans%Mod
#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

print(solve())
0