結果
| 問題 |
No.2568 列辞書順列列
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-09-10 08:08:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 155 ms / 3,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 1,971 ms |
| コンパイル使用メモリ | 201,040 KB |
| 最終ジャッジ日時 | 2025-02-24 06:29:46 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/modint>
#include<atcoder/segtree>
using namespace std;
using mint=atcoder::modint998244353;
int N,M,Q;
pair<mint,int>op(pair<mint,int>a, pair<mint,int>b)
{
mint val=a.first*mint(M).pow(b.second)+b.first;
int size=a.second+b.second;
return make_pair(val,size);
}
pair<mint,int>e(){return make_pair(mint(),0);}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M>>Q;
vector<pair<mint,int>>V(N);
for(int i=0;i<N;i++)
{
int A;
cin>>A;
V[i]=make_pair(A-1,1);
}
atcoder::segtree<pair<mint,int>,op,e>seg(V);
while(Q--)
{
int L,R;
cin>>L>>R;
L--;
mint ans=seg.prod(L,R).first+1;
cout<<ans.val()<<'\n';
}
}
nonon