結果
| 問題 | No.2229 Treasure Searching Rod (Hard) |
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-02-24 23:21:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 614 bytes |
| 記録 | |
| コンパイル時間 | 771 ms |
| コンパイル使用メモリ | 83,064 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 06:08:11 |
| 合計ジャッジ時間 | 3,308 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;
using lint = long long;
int main() {
cin.tie(nullptr), ios::sync_with_stdio(false);
lint H, W;
int K;
cin >> H >> W >> K;
mint ret = 0;
while (K--) {
lint x, y, v;
cin >> x >> y >> v;
lint lo = max<lint>(1, y - (x - 1)), wlo = x - abs(y - lo);
lint hi = min<lint>(W, y + (x - 1)), whi = x - abs(y - hi);
mint cnt = (wlo + x) * (y - lo + 1) / 2 + (whi + x) * (hi - y + 1) / 2 - x;
ret += cnt * v;
}
cout << ret.val() << endl;
}
hitonanode