結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー hiro71687khiro71687k
提出日時 2023-02-24 22:50:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,031 bytes
コンパイル時間 4,637 ms
コンパイル使用メモリ 262,588 KB
実行使用メモリ 814,780 KB
最終ジャッジ日時 2023-10-11 06:41:12
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,352 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 #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
ll inf=100000;
int main(){
    ll h,w,k;
    cin >> h >> w >> k;
    vector<ll>x(k),y(k),v(k);
    vector<vector<ll>>g(h,vector<ll>(w,0));
    for (ll i = 0; i < k; i++)
    {
        cin >> x[i] >> y[i] >> v[i];
    }
    ll ans=0;
    for (ll i = 0; i < k; i++)
    {
        y[i]=w+1-y[i];
        ll dx=x[i];
        ll dy=w-y[i]+1;
        ll z=0;
        if (dx<=dy)
        {
            z=((dx)*(dx+1))/2;
        }else{
            z=dy*(dx-dy);
            z%=mod;
            z+=((dy+1)*(dy))/2;
            z%=mod;
        }
        dx--,dy=w-dy;
        if (dx<=dy)
        {
            z+=(((dx)*(dx+1))/2)%mod;
            z%=mod;
        }else{
            z+=(dy*(dx-dy))%mod;
            z%=mod;
            z+=(((dy+1)*(dy))/2)%mod;
            z%=mod;
        }
        ans+=(z*v[i])%mod;
        ans%=mod;
    }
    cout << ans << endl;
}
0