結果

問題 No.1709 Indistinguishable by MEX
ユーザー hourenhouren
提出日時 2021-10-16 00:38:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 168,980 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 21:54:20
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 52 ms
4,348 KB
testcase_09 AC 42 ms
4,348 KB
testcase_10 AC 39 ms
4,348 KB
testcase_11 AC 32 ms
4,348 KB
testcase_12 AC 31 ms
4,348 KB
testcase_13 AC 46 ms
4,348 KB
testcase_14 AC 43 ms
4,348 KB
testcase_15 AC 45 ms
4,348 KB
testcase_16 AC 61 ms
4,348 KB
testcase_17 AC 56 ms
4,348 KB
testcase_18 AC 64 ms
4,348 KB
testcase_19 AC 64 ms
4,348 KB
testcase_20 AC 65 ms
4,348 KB
testcase_21 AC 65 ms
4,348 KB
testcase_22 AC 63 ms
4,348 KB
testcase_23 AC 62 ms
4,348 KB
testcase_24 AC 63 ms
4,348 KB
testcase_25 AC 62 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 33 ms
4,348 KB
testcase_28 AC 31 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> ainv(n);
    rep(i,n){
        int a;
        cin >> a;
        ainv[a] = i;
    }
    int be = min(ainv[0],ainv[1]), en = max(ainv[0],ainv[1]);
    ll ans = 1;
    for(int i=2;i<n;i++){
        if(chmin(be,ainv[i])) continue;
        else if(chmax(en,ainv[i])) continue;
        else ans = (ans * (en - be - i + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}
0