結果

問題 No.1709 Indistinguishable by MEX
ユーザー untiunti
提出日時 2021-05-28 00:19:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 169,184 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 19:44:28
合計ジャッジ時間 6,403 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 1 ms
4,348 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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 ;
   vector<ll> A(n) ;
   rep(i,n) cin>>A[i] ;
   vector<ll> pl(n) ;
   rep(i,n){
     rep(j,n){
       if(A[j]==i){
         pl[i]=j ; break ;
       }
     }
   }
   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 ;
   cout<<ans<<endl ;
   
   return 0  ;
}
0