結果
問題 | No.2229 Treasure Searching Rod (Hard) |
ユーザー |
|
提出日時 | 2023-02-24 21:46:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 4,389 ms |
コンパイル使用メモリ | 253,180 KB |
最終ジャッジ日時 | 2025-02-10 20:48:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;using mint = modint998244353;ll h,w,n;vector<ll> x,y,v;void solve(){mint ans = 0;for(int i =0 ;i<n;i++){mint keisu = mint(x[i])*mint(x[i]);ll lh = x[i]-y[i];lh = max(0ll,lh);ll rh = x[i]-(w-y[i]+1);rh = max(0ll,rh);//cout<<keisu.val()<<' '<<lh<<' '<<rh<<' ';keisu -= (rh*(rh+1)/2);keisu -= (lh*(lh+1)/2);ans += keisu*v[i];}cout<<ans.val()<<endl;}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> h >> w >> n;x = y = v = vector<ll>(n);for(int i = 0;i<n;i++){cin >> x[i] >> y[i] >> v[i];}solve();}