結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー daiotadaiota
提出日時 2023-02-25 06:14:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 165,700 KB
実行使用メモリ 8,252 KB
最終ジャッジ日時 2023-10-11 09:46:05
合計ジャッジ時間 6,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,464 KB
testcase_01 AC 1 ms
5,612 KB
testcase_02 AC 2 ms
5,416 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
5,416 KB
testcase_05 AC 1 ms
5,412 KB
testcase_06 AC 1 ms
5,464 KB
testcase_07 AC 56 ms
8,104 KB
testcase_08 AC 61 ms
8,176 KB
testcase_09 AC 56 ms
8,052 KB
testcase_10 AC 56 ms
8,124 KB
testcase_11 AC 54 ms
8,104 KB
testcase_12 AC 30 ms
6,672 KB
testcase_13 AC 31 ms
6,676 KB
testcase_14 AC 28 ms
6,680 KB
testcase_15 AC 62 ms
8,060 KB
testcase_16 AC 63 ms
8,056 KB
testcase_17 AC 63 ms
8,252 KB
testcase_18 AC 62 ms
8,112 KB
testcase_19 AC 62 ms
8,060 KB
testcase_20 AC 63 ms
8,180 KB
testcase_21 AC 62 ms
8,132 KB
testcase_22 AC 62 ms
8,044 KB
testcase_23 AC 25 ms
6,500 KB
testcase_24 AC 33 ms
6,832 KB
testcase_25 AC 38 ms
6,832 KB
testcase_26 AC 16 ms
6,328 KB
testcase_27 AC 6 ms
5,720 KB
testcase_28 AC 51 ms
7,528 KB
testcase_29 AC 49 ms
7,400 KB
testcase_30 AC 9 ms
5,756 KB
testcase_31 AC 14 ms
6,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(int i=0;i<int(n);i++)

const ll MOD=998244353;
ll x[200010],y[200010],v[200010];

int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j,k;

	ll H,W,K;
	cin >> H >> W >> K;

	for(i=1;i<=K;i++) cin >> x[i] >> y[i] >> v[i];

	ll ans=0;
	for(i=1;i<=K;i++){
		ll a=x[i],b=y[i];
		ll s=a*a;
		if(a+b-W>=2) s-=(a+b-W-1)*(a+b-W)/2;
		if(a-b>=1) s-=(a-b+1)*(a-b)/2;

		ans+=s*v[i];
		ans%=MOD;
	}

	cout << ans << endl;


	return 0;
}
0