結果

問題 No.1709 Indistinguishable by MEX
ユーザー se1ka2se1ka2
提出日時 2021-10-15 21:58:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 14,532 KB
最終ジャッジ日時 2023-10-17 20:17:08
合計ジャッジ時間 3,923 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 123 ms
12,588 KB
testcase_09 AC 98 ms
10,948 KB
testcase_10 AC 95 ms
10,600 KB
testcase_11 AC 68 ms
9,320 KB
testcase_12 AC 66 ms
9,160 KB
testcase_13 AC 95 ms
11,844 KB
testcase_14 AC 87 ms
11,184 KB
testcase_15 AC 90 ms
11,640 KB
testcase_16 AC 122 ms
14,100 KB
testcase_17 AC 113 ms
13,288 KB
testcase_18 AC 177 ms
14,532 KB
testcase_19 AC 157 ms
14,532 KB
testcase_20 AC 155 ms
14,532 KB
testcase_21 AC 128 ms
14,532 KB
testcase_22 AC 131 ms
14,532 KB
testcase_23 AC 106 ms
14,532 KB
testcase_24 AC 110 ms
14,532 KB
testcase_25 AC 107 ms
14,532 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 62 ms
9,672 KB
testcase_28 AC 58 ms
9,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int main()
{
    int n;
    cin >> n;
    int p[200005], r[200005];
    for(int i = 0; i < n; i++){
        cin >> p[i];
        r[p[i]] = i;
    }
    set<int> st;
    st.insert(r[0]);
    ll ans = 1;
    for(int i = 1; i < n; i++){
        if(r[i] > *st.begin() && r[i] < *st.rbegin()) ans = ans * (*st.rbegin() - *st.begin() - i + 1) % MOD;
        st.insert(r[i]);
    }
    cout << ans << endl;
}
0