結果

問題 No.2568 列辞書順列列
ユーザー DeltaStructDeltaStruct
提出日時 2023-11-03 22:39:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 3,000 ms
コード長 417 bytes
コンパイル時間 3,441 ms
コンパイル使用メモリ 247,704 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2023-11-03 22:40:02
合計ジャッジ時間 13,429 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 152 ms
4,348 KB
testcase_03 AC 155 ms
4,348 KB
testcase_04 AC 201 ms
8,092 KB
testcase_05 AC 192 ms
8,092 KB
testcase_06 AC 194 ms
8,092 KB
testcase_07 AC 193 ms
8,092 KB
testcase_08 AC 199 ms
8,092 KB
testcase_09 AC 234 ms
8,092 KB
testcase_10 AC 234 ms
8,092 KB
testcase_11 AC 254 ms
8,092 KB
testcase_12 AC 248 ms
8,092 KB
testcase_13 AC 250 ms
8,092 KB
testcase_14 AC 251 ms
8,092 KB
testcase_15 AC 251 ms
8,092 KB
testcase_16 AC 260 ms
8,092 KB
testcase_17 AC 228 ms
8,092 KB
testcase_18 AC 228 ms
8,092 KB
testcase_19 AC 234 ms
8,092 KB
testcase_20 AC 230 ms
8,092 KB
testcase_21 AC 245 ms
8,092 KB
testcase_22 AC 230 ms
8,092 KB
testcase_23 AC 237 ms
8,092 KB
testcase_24 AC 238 ms
8,092 KB
testcase_25 AC 240 ms
8,092 KB
testcase_26 AC 232 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n,m,q,a,b,mod(998244353); cin >> n >> m >> q;
  vector<ll> A(n),dp(n+1),pow(n+1,1);
  for (int i(0);i < n;++i){
    cin >> A[i]; --A[i];
    dp[i+1] = (dp[i]*m+A[i])%mod;
    pow[i+1] = (pow[i]*m)%mod;
  }
  while(q--){
    cin >> a >> b;
    a = (dp[b]-dp[a-1]*pow[b-a+1]+1)%mod;
    if (a<0) a=mod+a;
    cout << a << endl;
  }
}
0