結果
問題 |
No.2225 Treasure Searching Rod (Easy)
|
ユーザー |
|
提出日時 | 2023-02-25 02:07:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 959 bytes |
コンパイル時間 | 2,130 ms |
コンパイル使用メモリ | 197,660 KB |
最終ジャッジ日時 | 2025-02-10 23:05:09 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vll = vector<long long>; using vvll = vector<vector<long long>>; using vs = vector<string>; using vb = vector<bool>; using vvb = vector<vector<bool>>; #define lln \ ll n; \ cin >> n; #define REP(i, n) for (long long i = 0; i < n; i++) #define REPIN(v, n) \ for (long long i = 0; i < n; i++) cin >> v[i]; ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { ll H, W, K; cin >> H >> W >> K; vvll xyv(K, {0, 0, 0}); REP(i, K) { cin >> xyv[i][0] >> xyv[i][1] >> xyv[i][2]; } ll mod = 998244353, cnt = 0; REP(i, H) { REP(j, W) { REP(k, K) { if ((i + 1) + (j + 1) <= xyv[k][0] + xyv[k][1] && (i + 1) - (j + 1) <= xyv[k][0] - xyv[k][1]) { cnt += xyv[k][2]; cnt %= mod; } } } } cout << cnt % mod << endl; }