結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー 👑 KazunKazun
提出日時 2023-02-24 22:11:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 77,260 KB
最終ジャッジ日時 2023-10-11 06:20:52
合計ジャッジ時間 6,518 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,156 KB
testcase_01 AC 76 ms
71,228 KB
testcase_02 AC 75 ms
70,944 KB
testcase_03 AC 78 ms
71,024 KB
testcase_04 AC 77 ms
71,160 KB
testcase_05 AC 78 ms
71,220 KB
testcase_06 AC 78 ms
70,820 KB
testcase_07 AC 152 ms
76,876 KB
testcase_08 AC 143 ms
76,592 KB
testcase_09 AC 170 ms
77,260 KB
testcase_10 AC 142 ms
76,960 KB
testcase_11 AC 141 ms
76,728 KB
testcase_12 AC 122 ms
76,492 KB
testcase_13 AC 123 ms
76,976 KB
testcase_14 AC 122 ms
77,148 KB
testcase_15 AC 165 ms
77,000 KB
testcase_16 AC 166 ms
77,240 KB
testcase_17 AC 164 ms
76,824 KB
testcase_18 AC 171 ms
76,996 KB
testcase_19 AC 164 ms
76,996 KB
testcase_20 AC 169 ms
77,096 KB
testcase_21 AC 168 ms
77,020 KB
testcase_22 AC 170 ms
77,168 KB
testcase_23 AC 121 ms
77,176 KB
testcase_24 AC 125 ms
76,916 KB
testcase_25 AC 130 ms
76,948 KB
testcase_26 AC 115 ms
76,792 KB
testcase_27 AC 102 ms
76,860 KB
testcase_28 AC 152 ms
77,076 KB
testcase_29 AC 153 ms
77,240 KB
testcase_30 AC 102 ms
76,952 KB
testcase_31 AC 110 ms
76,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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