結果

問題 No.2571 列辞書順列
ユーザー 沙耶花沙耶花
提出日時 2023-12-06 01:52:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,027 bytes
コンパイル時間 4,631 ms
コンパイル使用メモリ 268,792 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-09 18:09:47
合計ジャッジ時間 15,516 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 139 ms
6,548 KB
testcase_03 AC 137 ms
6,548 KB
testcase_04 AC 321 ms
6,548 KB
testcase_05 AC 322 ms
6,548 KB
testcase_06 AC 429 ms
6,548 KB
testcase_07 AC 430 ms
6,676 KB
testcase_08 AC 254 ms
6,676 KB
testcase_09 AC 249 ms
6,676 KB
testcase_10 AC 345 ms
6,676 KB
testcase_11 AC 348 ms
6,676 KB
testcase_12 AC 346 ms
6,676 KB
testcase_13 AC 346 ms
6,676 KB
testcase_14 AC 342 ms
6,676 KB
testcase_15 AC 341 ms
6,676 KB
testcase_16 AC 346 ms
6,676 KB
testcase_17 AC 347 ms
6,676 KB
testcase_18 AC 348 ms
6,676 KB
testcase_19 AC 348 ms
6,676 KB
testcase_20 AC 341 ms
6,676 KB
testcase_21 AC 343 ms
6,676 KB
testcase_22 AC 343 ms
6,676 KB
testcase_23 AC 342 ms
6,676 KB
testcase_24 AC 342 ms
6,676 KB
testcase_25 AC 341 ms
6,676 KB
testcase_26 AC 342 ms
6,676 KB
testcase_27 AC 345 ms
6,676 KB
testcase_28 AC 343 ms
6,676 KB
testcase_29 AC 343 ms
6,676 KB
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001
int N,M,Q;

using P = pair<mint,int>;

P op(P a,P b){
	swap(a,b);
	a.first += b.first * mint(M).pow(a.second);
	a.second += b.second;
	return a;
}

P e(){
	return make_pair(0,0);
}


int main(){
	int K;
	cin>>N>>M>>K>>Q;
	
	segtree<P,op,e> seg(N);
	fenwick_tree<mint> F(N);
	rep(i,N){
		int a;
		cin>>a;
		a--;
		seg.set(i,make_pair(mint(a),1));
		F.add(i,mint(a));
	}
	rep(i,Q){
		int t;
		cin>>t;
		if(t==1){
			int l,r;
			cin>>l>>r;
			auto ret = seg.prod(l-1,r);
			mint ans = ret.first;
			ans *= mint(M).pow(K-ret.second+1);
			ans -= F.sum(l-1,r);
			ans /= M-1;
			ans += r-l;
			ans++;
			cout<<ans.val()<<endl;
		}
		else{
			int x,y;
			cin>>x>>y;
			x--,y--;
			seg.set(x,make_pair(mint(y),1));
			F.add(x,-F.sum(x,x+1));
			F.add(x,mint(y));
		}
	}
	
	return 0;
}
0