結果

問題 No.2225 Treasure Searching Rod (Easy)
ユーザー 佐藤篤樹
提出日時 2023-04-29 16:46:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 2,366 bytes
コンパイル時間 3,462 ms
コンパイル使用メモリ 234,372 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 11:44:46
合計ジャッジ時間 4,384 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

using namespace atcoder;
typedef long long ll;
typedef long double dd;
typedef unsigned long long ull;

typedef vector<ll> vl;
typedef vector<dd> vd;
typedef vector<bool> vb;
typedef vector<pair<ll,ll>> vl_l;

typedef vector<vector<ll>> vvl;
typedef vector<vector<dd>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<pair<ll,ll>>> vvl_l;

typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<dd>>> vvvd;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<vector<vector<pair<ll,ll>>>> vvvl_l;

typedef map<ll,ll> ml;
typedef set<ll> sl;

// #define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-9;
dd PI=acos(-1);
// #define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = (T)b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = (T)b;
        return true;
    }
    return false;
}
ll hpow(ll x,ll y){
    if(y==0)return 1;
    ll res=hpow(x,y/2);
    res = mod(res*res);
    if(y%2==1){
        res *= x;
        res = mod(res);
    }
    return mod(res);
}
ll hpow_m(ll x,ll y,ll m){
    if(y==0)return 1;
    ll res=hpow_m(x,y/2,m);
    res = (res*res)%m;
    if(y%2==1){
        res *= x;
        res %= m;
    }
    return res%m;
}





signed main(){fastio
    
    ll h,w;cin>>h>>w;
    ll k;cin>>k;
    map<l_l, ll> mp;
    
    vvl v(h+1);
    rep(i,0,h)v[i].resize(w+1, 0);
    rep(i,1,k){
        ll x,y,k;cin>>x>>y>>k;
        v[x][y] = k;
    }
    
    ll ans = 0;
    rep(i,1,h){
        rep(j,1,w){
            rep(x,1,h){
                rep(y,1,w){
                    if(x + y >= i + j && x - y >= i - j){
                        ans += v[x][y];
                    }
                }
            }
            ans = mod(ans);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}







0