結果
問題 | No.2229 Treasure Searching Rod (Hard) |
ユーザー |
![]() |
提出日時 | 2023-02-24 22:55:15 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 1,006 ms |
コンパイル使用メモリ | 28,416 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:57:59 |
合計ジャッジ時間 | 3,752 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}