結果
| 問題 | No.2229 Treasure Searching Rod (Hard) |
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-02-24 22:55:15 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| + 519µs | |
| コード長 | 822 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 36,608 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-23 07:12:51 |
| 合計ジャッジ時間 | 5,280 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <stdio.h>
int main () {
int h = 0;
long long w = 0LL;
int k = 0;
long long x = 0LL;
long long y = 0LL;
long long v = 0LL;
int res = 0;
long long ans = 0LL;
long long mod_num = 998244353LL;
res = scanf("%d", &h);
res = scanf("%lld", &w);
res = scanf("%d", &k);
for (int i = 0; i < k; i++) {
long long cnt = 0LL;
res = scanf("%lld", &x);
res = scanf("%lld", &y);
res = scanf("%lld", &v);
cnt = (x*x)%mod_num;
if (x-y > 0LL) {
cnt -= (((x-y)*(x-y+1LL))/2LL)%mod_num;
cnt += mod_num;
cnt %= mod_num;
}
if (x-(w-y+1LL) > 0LL) {
cnt -= (((x-(w-y+1LL))*(x-(w-y+1LL)+1LL))/2LL)%mod_num;
cnt += mod_num;
cnt %= mod_num;
}
ans += cnt*v;
ans %= mod_num;
}
printf("%lld\n", ans%mod_num);
return 0;
}
chro_96