結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー FromBooskaFromBooska
提出日時 2023-03-05 11:32:38
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 951 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 844,132 KB
最終ジャッジ日時 2023-10-18 04:49:27
合計ジャッジ時間 6,002 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,432 KB
testcase_01 AC 40 ms
53,432 KB
testcase_02 AC 37 ms
53,432 KB
testcase_03 AC 37 ms
53,432 KB
testcase_04 AC 38 ms
53,432 KB
testcase_05 AC 38 ms
53,432 KB
testcase_06 AC 37 ms
53,432 KB
testcase_07 MLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# こっちは制約が大きいので寄与度
# 各数の寄与度は、そのマスを下の頂点とした逆三角形の面積
# その逆三角形の面積を高速に計算できないか
# dp表みたいにできないか、できない
# 計算式で求めてみる、逆三角形を右半分+左半分-ダブルカウントした真ん中で計算

H, W, K = map(int, input().split())
mod = 998244353
contribution = [[0]*W for h in range(H)]
for i in range(H):
    for j in range(W):
        r = min(i+1, W - j - 1)
        right = r*(r+1)//2 + (i+1-r)*(W-j)
        right %= mod
        l = min(i+1, j+1)
        left = l*(l+1)//2 + (i+1-l)*(j+1)
        left %= mod
        center = i+1
        calc = (right + left - center)%mod
        contribution[i][j] = calc
        #print('i', i, 'j', j, 'calc', calc)

ans = 0
for i in range(K):
    x, y, v = map(int, input().split())
    ans += contribution[x-1][y-1]*v
    ans %= mod
print(ans)
0