結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー lddlinanlddlinan
提出日時 2023-03-02 12:48:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 84,636 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 10:03:40
合計ジャッジ時間 6,099 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 55 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 56 ms
4,348 KB
testcase_10 AC 54 ms
4,348 KB
testcase_11 AC 54 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 30 ms
4,348 KB
testcase_14 AC 29 ms
4,348 KB
testcase_15 AC 62 ms
4,348 KB
testcase_16 AC 61 ms
4,348 KB
testcase_17 AC 61 ms
4,348 KB
testcase_18 AC 61 ms
4,348 KB
testcase_19 AC 61 ms
4,348 KB
testcase_20 AC 61 ms
4,348 KB
testcase_21 AC 61 ms
4,348 KB
testcase_22 AC 61 ms
4,348 KB
testcase_23 AC 24 ms
4,348 KB
testcase_24 AC 32 ms
4,348 KB
testcase_25 AC 37 ms
4,348 KB
testcase_26 AC 15 ms
4,348 KB
testcase_27 AC 6 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 47 ms
4,348 KB
testcase_30 AC 8 ms
4,348 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;


#define MOD 998244353
int main() {
    int n, i, s, e, x, y, v, d;
    int h, w, k;
    LL r=0, t, c, cc;
    scanf("%d %d %d", &h, &w, &k);
    for (i=0; i<k; i++) {
        scanf("%d %d %d", &x, &y, &v);
        // count
        x--; y--;
        s=y-x; e=x+y; 
        // 1+... 1+x
        c=(1+1+x*2); c*=(x+1); c/=2; c%=MOD;
        if (s<0) {
            d=-s;
            cc=(1+d); cc*=d; cc/=2;  c-=cc; if (c<0) c+=MOD;
        }
        if (e>=w) {
            d=e-w+1;
            cc=(1+d); cc*=d; cc/=2;  c-=cc; if (c<0) c+=MOD;
        }
        // printf("%d,%d(%d,%d) ==>%lld\n", x, y,s, e, c);
        t=v; t*=c; t%=MOD;
        r+=t; r%=MOD;
    }
    printf("%lld\n", r);

    return 0;
}
0