結果

問題 No.2225 Treasure Searching Rod (Easy)
ユーザー napier
提出日時 2023-02-25 23:46:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,344 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 198,340 KB
最終ジャッジ日時 2025-02-10 23:28:44
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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