結果

問題 No.2225 Treasure Searching Rod (Easy)
ユーザー napiernapier
提出日時 2023-02-25 23:46:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,344 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 202,420 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 18:57:28
合計ジャッジ時間 3,373 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,n-1,-1)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define sort(x) sort(all(x))
#define rev(x) reverse(all(x))

const ll inf = (1LL<<60)+(1LL<<30);

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll H, W, K;
    cin >> H >> W >> K;

    vector<vll> field(H+1, vll(W+1));
    ll x, y, v;
    rep(i, K) {
        cin >> x >> y >> v;
        field[x][y] = v;
    }

    auto op = [&](ll i, ll j) { 
        ll res = 0;
        rep(x, 1, H+1) rep(y, 1, W+1) {
            if (x+y >= i+j && x-y >= i-j) res += field[x][y];
        }
        return res;
    };

    ll ans = 0;

    rep(i, 1, H+1) rep(j, 1, W+1) {
        ans += op(i, j);
        ans %= 998244353;
    } 

    cout << ans << endl;
}
0