結果
問題 | No.2225 Treasure Searching Rod (Easy) |
ユーザー |
![]() |
提出日時 | 2023-02-24 23:02:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 1,629 ms |
コンパイル使用メモリ | 192,744 KB |
最終ジャッジ日時 | 2025-02-10 22:12:25 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;const ll MOD=998244353;const ll INF=998244353000000000;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);ll h,w,k;cin>>h>>w>>k;auto f=[&](ll x,ll y)->ll{ll tmp=x+1;tmp=(tmp+x*(x+1)%MOD);if(x>y) tmp=(tmp-(x-y)*(x-y+1)/2+INF)%MOD;if(w-y-1<x) tmp=(tmp-(x-w+y+1)*(x-w+y+2)/2+INF)%MOD;return tmp;};ll ans=0;rep(i,k){ll x,y,v;cin>>x>>y>>v;x--,y--;ans=(ans+v*f(x,y))%MOD;}cout<<ans<<endl;return 0;}