結果

問題 No.1709 Indistinguishable by MEX
ユーザー asaringoasaringo
提出日時 2022-05-29 20:37:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 205,816 KB
実行使用メモリ 6,840 KB
最終ジャッジ日時 2023-10-21 00:12:10
合計ジャッジ時間 5,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 64 ms
6,280 KB
testcase_09 AC 52 ms
6,236 KB
testcase_10 AC 50 ms
6,236 KB
testcase_11 AC 41 ms
6,236 KB
testcase_12 AC 39 ms
6,236 KB
testcase_13 AC 58 ms
6,236 KB
testcase_14 AC 53 ms
6,236 KB
testcase_15 AC 56 ms
6,236 KB
testcase_16 AC 74 ms
6,712 KB
testcase_17 AC 68 ms
6,484 KB
testcase_18 AC 79 ms
6,840 KB
testcase_19 AC 79 ms
6,840 KB
testcase_20 AC 79 ms
6,840 KB
testcase_21 AC 78 ms
6,840 KB
testcase_22 AC 78 ms
6,840 KB
testcase_23 AC 85 ms
6,840 KB
testcase_24 AC 84 ms
6,840 KB
testcase_25 AC 83 ms
6,840 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 36 ms
6,236 KB
testcase_28 AC 32 ms
6,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<bool,ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

const int mod = 998244353 ;

int n ;
P A[202020] ;
bool B[202020] ;

int main(){
    cin >> n ;
    rep(i,n) {
        int a ;
        cin >> a ;
        A[i] = P(a,i) ;
    }
    if(n == 1){
        cout << 1 << endl ;
        return 0 ;
    }
    sort(A,A+n) ;
    ll res = 1 ;
    int lef = n , rig = -1 ;
    rep(i,n){
        int id = A[i].second ;
        chmax(rig,id) ;
        chmin(lef,id) ;
        if(id == rig || id == lef) continue;
        ll sec = rig - lef + 1 ;
        ll cnt = sec - i ;
        (res *= cnt) %= mod ;
    }
    cout << res << endl ;
}
0