結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー flygon
提出日時 2023-02-24 23:51:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 91,892 KB
最終ジャッジ日時 2024-09-13 06:13:57
合計ジャッジ時間 6,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w,k = map(int,input().split())
ans = 0
mod =998244353
now = 1
xx = [0]
for i in range(2*10**5):
  xx.append(xx[-1] + now)
  now += 2
  now %= mod
for i in range(k):
  x,y,v = map(int,input().split())
  cnt = xx[x]
  lcnt = max(0,x-y)
  rcnt = max(0, x-(w-y+1))
  cnt -= lcnt*(lcnt+1)//2 + rcnt*(rcnt+1)//2
  cnt %= mod
  ans += v * cnt
  ans %= mod

print(ans)
0