結果
| 問題 |
No.2225 Treasure Searching Rod (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-24 21:46:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 686 bytes |
| コンパイル時間 | 3,261 ms |
| コンパイル使用メモリ | 251,692 KB |
| 最終ジャッジ日時 | 2025-02-10 20:47:26 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#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();
}