結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-12-07 09:48:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 78,964 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-21 19:58:02
合計ジャッジ時間 7,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 188 ms
7,936 KB
testcase_08 AC 209 ms
7,936 KB
testcase_09 AC 182 ms
7,936 KB
testcase_10 AC 187 ms
7,936 KB
testcase_11 AC 181 ms
8,064 KB
testcase_12 AC 104 ms
5,504 KB
testcase_13 AC 104 ms
5,888 KB
testcase_14 AC 90 ms
5,504 KB
testcase_15 AC 206 ms
7,936 KB
testcase_16 AC 207 ms
7,936 KB
testcase_17 AC 207 ms
7,936 KB
testcase_18 AC 207 ms
7,936 KB
testcase_19 AC 207 ms
7,936 KB
testcase_20 AC 208 ms
7,936 KB
testcase_21 AC 207 ms
7,936 KB
testcase_22 AC 208 ms
7,936 KB
testcase_23 AC 81 ms
5,376 KB
testcase_24 AC 106 ms
5,760 KB
testcase_25 AC 124 ms
6,016 KB
testcase_26 AC 48 ms
5,376 KB
testcase_27 AC 17 ms
5,376 KB
testcase_28 AC 167 ms
7,168 KB
testcase_29 AC 159 ms
6,784 KB
testcase_30 AC 24 ms
5,376 KB
testcase_31 AC 44 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

ll mod = 998244353;

ll GridCount(ll W, ll x, ll y){
    ll ret = 0;
    if (x <= y){
        ret += x * (x + 1) / 2;
    }
    else{
        ret += (x * (x + 1) / 2 - (x - y) * (x - y + 1) / 2);
    }

    if (x <= W - y + 1){
        ret += x * (x + 1) / 2;
    }
    else{
        ret += (x * (x + 1) / 2 - (x - (W - y + 1)) * (x - (W - y + 1) + 1) / 2);
    }
    ret -= x;
    return ret;
}

int main(){
    ll H,W,K;
    cin >> H >> W >> K;
    vector<ll> x(K);
    vector<ll> y(K);
    vector<ll> v(K);
    for (ll i = 0; i < K; i++){
        cin >> x[i] >> y[i] >> v[i];
    }
    ll ans = 0;
    for (ll i = 0; i < K; i++){
        ll grid_count = GridCount(W, x[i], y[i]) % mod;
        grid_count = (grid_count * v[i]) % mod;
        ans = (ans + grid_count) % mod;
    }
    cout << ans << endl;
}
0