結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー hiro71687khiro71687k
提出日時 2023-02-24 22:52:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 4,233 ms
コンパイル使用メモリ 259,616 KB
実行使用メモリ 8,032 KB
最終ジャッジ日時 2023-10-11 06:41:54
合計ジャッジ時間 9,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 178 ms
8,032 KB
testcase_08 AC 205 ms
7,804 KB
testcase_09 AC 177 ms
7,816 KB
testcase_10 AC 177 ms
7,804 KB
testcase_11 AC 171 ms
7,804 KB
testcase_12 AC 99 ms
5,404 KB
testcase_13 AC 100 ms
5,396 KB
testcase_14 AC 88 ms
5,376 KB
testcase_15 AC 198 ms
7,808 KB
testcase_16 AC 199 ms
7,932 KB
testcase_17 AC 199 ms
7,936 KB
testcase_18 AC 198 ms
7,756 KB
testcase_19 AC 198 ms
7,960 KB
testcase_20 AC 198 ms
7,756 KB
testcase_21 AC 198 ms
7,864 KB
testcase_22 AC 198 ms
7,900 KB
testcase_23 AC 78 ms
4,820 KB
testcase_24 AC 102 ms
5,432 KB
testcase_25 AC 116 ms
5,904 KB
testcase_26 AC 47 ms
4,348 KB
testcase_27 AC 16 ms
4,352 KB
testcase_28 AC 162 ms
6,968 KB
testcase_29 AC 152 ms
6,784 KB
testcase_30 AC 23 ms
4,352 KB
testcase_31 AC 42 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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);
    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