結果

問題 No.2229 Treasure Searching Rod (Hard)
コンテスト
ユーザー 👑 Kazun
提出日時 2023-02-24 22:11:19
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 93 ms / 2,000 ms
+ 176µs
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 82 ms
コンパイル使用メモリ 64,932 KB
実行使用メモリ 59,340 KB
最終ジャッジ日時 2026-10-17 01:55:50
合計ジャッジ時間 6,480 ms
ジャッジサーバーID
(参考情報)
judge4_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