結果
問題 | No.2229 Treasure Searching Rod (Hard) |
ユーザー |
👑 ![]() |
提出日時 | 2022-12-07 09:48:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 75,480 KB |
最終ジャッジ日時 | 2025-02-09 06:01:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <vector> #include <map> using namespace std; typedef long long ll; ll mod = 998244353; ll GridCount(ll W, ll x, ll y){ ll ret = 0; if (x <= y){ ret += x * (x + 1) / 2; } else{ ret += (x * (x + 1) / 2 - (x - y) * (x - y + 1) / 2); } if (x <= W - y + 1){ ret += x * (x + 1) / 2; } else{ ret += (x * (x + 1) / 2 - (x - (W - y + 1)) * (x - (W - y + 1) + 1) / 2); } ret -= x; return ret; } int main(){ ll H,W,K; cin >> H >> W >> K; vector<ll> x(K); vector<ll> y(K); vector<ll> v(K); for (ll i = 0; i < K; i++){ cin >> x[i] >> y[i] >> v[i]; } ll ans = 0; for (ll i = 0; i < K; i++){ ll grid_count = GridCount(W, x[i], y[i]) % mod; grid_count = (grid_count * v[i]) % mod; ans = (ans + grid_count) % mod; } cout << ans << endl; }