結果

問題 No.1709 Indistinguishable by MEX
ユーザー trineutrontrineutron
提出日時 2021-10-15 22:20:02
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 2,853 ms
コンパイル使用メモリ 248,132 KB
実行使用メモリ 4,904 KB
最終ジャッジ日時 2023-10-17 20:26:39
合計ジャッジ時間 5,049 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 52 ms
4,640 KB
testcase_09 AC 42 ms
4,376 KB
testcase_10 AC 40 ms
4,376 KB
testcase_11 AC 32 ms
4,348 KB
testcase_12 AC 31 ms
4,348 KB
testcase_13 AC 48 ms
4,640 KB
testcase_14 AC 44 ms
4,376 KB
testcase_15 AC 47 ms
4,376 KB
testcase_16 AC 61 ms
4,904 KB
testcase_17 AC 56 ms
4,640 KB
testcase_18 AC 67 ms
4,904 KB
testcase_19 AC 66 ms
4,904 KB
testcase_20 AC 66 ms
4,904 KB
testcase_21 AC 63 ms
4,904 KB
testcase_22 AC 63 ms
4,904 KB
testcase_23 AC 63 ms
4,904 KB
testcase_24 AC 63 ms
4,904 KB
testcase_25 AC 63 ms
4,904 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 35 ms
4,348 KB
testcase_28 AC 31 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main()
{
    int n;
    cin >> n;
    int l = n, r = -1;
    vector<int> p(n), idx(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
        idx.at(p.at(i)) = i;
    }
    mint ans = 1;
    for (int i = 0; i < n; i++)
    {
        int v = r - l + 1 - i;
        if (idx.at(i) < l)
        {
            l = idx.at(i);
            v = 1;
        }
        if (idx.at(i) > r)
        {
            r = idx.at(i);
            v = 1;
        }
        ans *= v;
    }
    cout << ans.val() << endl;
    return 0;
}
0