結果

問題 No.1709 Indistinguishable by MEX
ユーザー untiunti
提出日時 2021-05-28 01:03:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 169,464 KB
実行使用メモリ 6,460 KB
最終ジャッジ日時 2023-10-17 19:44:32
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge14 / 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
5,932 KB
testcase_09 AC 42 ms
5,404 KB
testcase_10 AC 40 ms
5,404 KB
testcase_11 AC 32 ms
4,876 KB
testcase_12 AC 31 ms
4,876 KB
testcase_13 AC 47 ms
5,668 KB
testcase_14 AC 43 ms
5,404 KB
testcase_15 AC 46 ms
5,668 KB
testcase_16 AC 60 ms
6,196 KB
testcase_17 AC 55 ms
6,196 KB
testcase_18 AC 63 ms
6,460 KB
testcase_19 AC 63 ms
6,460 KB
testcase_20 AC 63 ms
6,460 KB
testcase_21 AC 63 ms
6,460 KB
testcase_22 AC 63 ms
6,460 KB
testcase_23 AC 63 ms
6,460 KB
testcase_24 AC 63 ms
6,460 KB
testcase_25 AC 63 ms
6,460 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 35 ms
5,140 KB
testcase_28 AC 31 ms
4,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define fi first 
#define se second

const ll mod=998244353ll ;

int main(){
   ll n ; cin>>n ;
   assert(n<=2e5) ;
   vector<ll> A(n) ;
   rep(i,n) cin>>A[i] ;
   vector<ll> pl(n) ;
   rep(i,n) pl[A[i]]=i ;
   ll ans=1ll ;
   ll l=pl[0] ;
   ll r=pl[0] ;
   rep(i,n-1){
    if(pl[i+1]<l) l=pl[i+1] ;
    else if(r<pl[i+1]) r=pl[i+1] ;
    else ans*=(r-l-i) ;
    ans%=mod ;
   }
   
   ans%=mod ;
   cout<<ans<<endl ;
   
   return 0  ;
}
0