結果

問題 No.2568 列辞書順列列
ユーザー 沙耶花沙耶花
提出日時 2023-12-06 01:25:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 519 ms / 3,000 ms
コード長 663 bytes
コンパイル時間 4,740 ms
コンパイル使用メモリ 265,992 KB
実行使用メモリ 8,984 KB
最終ジャッジ日時 2023-12-06 01:25:43
合計ジャッジ時間 19,693 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 169 ms
6,676 KB
testcase_03 AC 169 ms
6,676 KB
testcase_04 AC 398 ms
8,984 KB
testcase_05 AC 397 ms
8,984 KB
testcase_06 AC 424 ms
8,984 KB
testcase_07 AC 397 ms
8,984 KB
testcase_08 AC 397 ms
8,984 KB
testcase_09 AC 434 ms
8,984 KB
testcase_10 AC 426 ms
8,984 KB
testcase_11 AC 459 ms
8,984 KB
testcase_12 AC 493 ms
8,984 KB
testcase_13 AC 496 ms
8,984 KB
testcase_14 AC 503 ms
8,984 KB
testcase_15 AC 495 ms
8,984 KB
testcase_16 AC 507 ms
8,984 KB
testcase_17 AC 488 ms
8,984 KB
testcase_18 AC 519 ms
8,984 KB
testcase_19 AC 484 ms
8,984 KB
testcase_20 AC 518 ms
8,984 KB
testcase_21 AC 485 ms
8,984 KB
testcase_22 AC 487 ms
8,984 KB
testcase_23 AC 488 ms
8,984 KB
testcase_24 AC 496 ms
8,984 KB
testcase_25 AC 513 ms
8,984 KB
testcase_26 AC 484 ms
8,984 KB
権限があれば一括ダウンロードができます

ソースコード

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(){
	
	cin>>N>>M>>Q;
	
	segtree<P,op,e> seg(N);
	rep(i,N){
		int a;
		cin>>a;
		a--;
		seg.set(i,make_pair(mint(a),1));
	}
	rep(i,Q){
		int l,r;
		cin>>l>>r;
		cout<<(seg.prod(l-1,r).first+1).val()<<endl;
	}
	
	return 0;
}
0