結果
| 問題 | No.2229 Treasure Searching Rod (Hard) |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-12-07 09:48:41 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 906 bytes |
| 記録 | |
| コンパイル時間 | 589 ms |
| コンパイル使用メモリ | 92,928 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2026-06-28 18:46:33 |
| 合計ジャッジ時間 | 7,104 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}