結果

問題 No.2568 列辞書順列列
ユーザー maeshunmaeshun
提出日時 2023-12-02 15:41:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 324 ms / 3,000 ms
コード長 1,015 bytes
コンパイル時間 4,825 ms
コンパイル使用メモリ 266,536 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2023-12-02 15:41:19
合計ジャッジ時間 14,281 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 161 ms
6,548 KB
testcase_03 AC 170 ms
6,548 KB
testcase_04 AC 243 ms
6,912 KB
testcase_05 AC 259 ms
6,912 KB
testcase_06 AC 242 ms
6,912 KB
testcase_07 AC 255 ms
6,912 KB
testcase_08 AC 251 ms
6,912 KB
testcase_09 AC 290 ms
6,912 KB
testcase_10 AC 308 ms
6,912 KB
testcase_11 AC 292 ms
6,912 KB
testcase_12 AC 303 ms
6,912 KB
testcase_13 AC 304 ms
6,912 KB
testcase_14 AC 324 ms
6,912 KB
testcase_15 AC 298 ms
6,912 KB
testcase_16 AC 304 ms
6,912 KB
testcase_17 AC 291 ms
6,912 KB
testcase_18 AC 283 ms
6,912 KB
testcase_19 AC 273 ms
6,912 KB
testcase_20 AC 277 ms
6,912 KB
testcase_21 AC 281 ms
6,912 KB
testcase_22 AC 282 ms
6,912 KB
testcase_23 AC 279 ms
6,912 KB
testcase_24 AC 274 ms
6,912 KB
testcase_25 AC 289 ms
6,912 KB
testcase_26 AC 268 ms
6,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

mint op(mint a, mint b){
    return a + b;
}

mint e(){
    return 0;
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    segtree<mint, op, e> seg(n);
    rep(i,n){
        seg.set(i, (a[i]-1)*mint(m).pow(n-i-1));
        dbg((a[i]-1)*mint(m).pow(n-i-1).val());
    }
    rep(_,q){
        int l, r;
        cin >> l >> r;
        --l;;
        mint val = seg.prod(l,r);
        val *= mint(m).pow(n-r).inv();
        val += 1;
        cout << val.val() << endl;
    }
    return 0;
}
0