結果

問題 No.1709 Indistinguishable by MEX
ユーザー hiro71687khiro71687k
提出日時 2023-04-02 19:57:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 5,722 ms
コンパイル使用メモリ 261,952 KB
実行使用メモリ 6,516 KB
最終ジャッジ日時 2023-10-25 05:11:04
合計ジャッジ時間 7,009 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 1 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 53 ms
5,988 KB
testcase_09 AC 44 ms
5,460 KB
testcase_10 AC 41 ms
5,460 KB
testcase_11 AC 34 ms
4,932 KB
testcase_12 AC 33 ms
4,932 KB
testcase_13 AC 47 ms
5,724 KB
testcase_14 AC 44 ms
5,460 KB
testcase_15 AC 46 ms
5,724 KB
testcase_16 AC 62 ms
6,252 KB
testcase_17 AC 57 ms
5,988 KB
testcase_18 AC 68 ms
6,516 KB
testcase_19 AC 69 ms
6,516 KB
testcase_20 AC 68 ms
6,516 KB
testcase_21 AC 64 ms
6,516 KB
testcase_22 AC 63 ms
6,516 KB
testcase_23 AC 60 ms
6,516 KB
testcase_24 AC 59 ms
6,516 KB
testcase_25 AC 60 ms
6,516 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 33 ms
5,196 KB
testcase_28 AC 29 ms
4,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=1444999994999999;
ll mod=998244353;
int main(){
    ll n;
    cin >> n;
    vector<ll>p(n);
    ll left=inf,right=0;
    vector<ll>memo(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> p[i];
        memo[p[i]]=i;
        if (p[i]==0||p[i]==1)
        {
            left=min(left,i);
            right=max(right,i);
        }
    }
    ll ans=1;
    for (ll i = 2; i < n; i++)
    {
        if (left<=memo[i]&&memo[i]<=right)
        {
            ans*=(right-left-i+1);
            ans%=mod;
        }
        left=min(left,memo[i]);
        right=max(memo[i],right);
    }
    cout << ans << endl;
}
0