結果

問題 No.2225 Treasure Searching Rod (Easy)
ユーザー ninja-kidninja-kid
提出日時 2023-02-25 00:55:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,560 bytes
コンパイル時間 5,588 ms
コンパイル使用メモリ 312,212 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 07:23:37
合計ジャッジ時間 6,522 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 13 ms
4,352 KB
testcase_08 AC 12 ms
4,348 KB
testcase_09 AC 13 ms
4,352 KB
testcase_10 AC 11 ms
4,348 KB
testcase_11 AC 10 ms
4,352 KB
testcase_12 AC 13 ms
4,348 KB
testcase_13 AC 12 ms
4,372 KB
testcase_14 AC 13 ms
4,352 KB
testcase_15 AC 11 ms
4,356 KB
testcase_16 AC 11 ms
4,352 KB
testcase_17 AC 11 ms
4,348 KB
testcase_18 AC 11 ms
4,356 KB
testcase_19 AC 11 ms
4,352 KB
testcase_20 AC 11 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 4 ms
4,348 KB
testcase_24 AC 5 ms
4,352 KB
testcase_25 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n, m) for (int i = (int)(n); i > (int)(m); i--)
#define rep1(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() using namespace atcoder;
using ll = long long;
const ll MOD1 = 1000000007LL;
const ll MOD2 = 998244353LL;
using namespace std;
using namespace atcoder;
const vector<pair<int, int>> dpos4 = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// const vector<pair<int, int>> dpos8 = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template<typename T>
T pow(T a, ll b){
    if(b == 0) return 1;
    if(b % 2 == 0) return pow(a / 2, b / 2);
    return a * pow(a, b - 1);
}

using mint = modint998244353;
int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<mint>> treasures(H, vector<mint>(W, 0));
    rep(i, K){
        int a, b; ll c;
        cin >> a >> b >> c;
        a--, b--;
        treasures[a][b] += c;
    }

    mint ans = 0;
    rep(h, H) rep(w, W) rep(i, H) rep(j, W){
        if(i + j >= h + w && i - j >= h - w){
            ans += treasures[i][j];
        }
    }
    cout << ans.val() << endl;
	return 0;
}
0