結果

問題 No.2568 列辞書順列列
ユーザー 👑 deuteridayodeuteridayo
提出日時 2023-10-26 19:44:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 601 ms / 3,000 ms
コード長 755 bytes
コンパイル時間 4,542 ms
コンパイル使用メモリ 265,844 KB
実行使用メモリ 10,656 KB
最終ジャッジ日時 2023-10-28 06:44:04
合計ジャッジ時間 20,053 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 166 ms
4,348 KB
testcase_03 AC 165 ms
4,348 KB
testcase_04 AC 482 ms
10,656 KB
testcase_05 AC 484 ms
10,656 KB
testcase_06 AC 489 ms
10,656 KB
testcase_07 AC 485 ms
10,656 KB
testcase_08 AC 487 ms
10,656 KB
testcase_09 AC 505 ms
10,656 KB
testcase_10 AC 508 ms
10,656 KB
testcase_11 AC 504 ms
10,656 KB
testcase_12 AC 594 ms
10,656 KB
testcase_13 AC 595 ms
10,656 KB
testcase_14 AC 587 ms
10,656 KB
testcase_15 AC 584 ms
10,656 KB
testcase_16 AC 585 ms
10,656 KB
testcase_17 AC 590 ms
10,656 KB
testcase_18 AC 596 ms
10,656 KB
testcase_19 AC 588 ms
10,656 KB
testcase_20 AC 595 ms
10,656 KB
testcase_21 AC 597 ms
10,656 KB
testcase_22 AC 601 ms
10,656 KB
testcase_23 AC 600 ms
10,656 KB
testcase_24 AC 600 ms
10,656 KB
testcase_25 AC 597 ms
10,656 KB
testcase_26 AC 601 ms
10,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using lint = long long;
#define endl '\n'
using mint = modint998244353;
lint mod = 998244353;
#define rep(i, n) for(int i = 0; i < n; i++)
#define vec vector

int n,m,q;
struct S {
    mint val;
    int len;
};

S op(S l, S r) {
    return {l.val * pow_mod(m, r.len, mod) + r.val, l.len+r.len};
};

S e() {
    return {0,0};
}

int main(){
    cin >> n >> m >> q;
    lint a[n];
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    segtree<S, op, e>segt(n);
    rep(i, n) {
        segt.set(i, {a[i], 1});
    }
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--;r--;
        cout << (segt.prod(l, r+1).val+1).val() << endl;
    }

}

0