結果

問題 No.1709 Indistinguishable by MEX
ユーザー umezoumezo
提出日時 2021-10-16 00:03:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 203,588 KB
実行使用メモリ 6,372 KB
最終ジャッジ日時 2023-10-17 21:50:17
合計ジャッジ時間 3,612 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 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 21 ms
5,844 KB
testcase_09 AC 17 ms
5,316 KB
testcase_10 AC 17 ms
5,316 KB
testcase_11 AC 13 ms
4,788 KB
testcase_12 AC 12 ms
4,788 KB
testcase_13 AC 18 ms
5,580 KB
testcase_14 AC 16 ms
5,316 KB
testcase_15 AC 18 ms
5,580 KB
testcase_16 AC 22 ms
6,108 KB
testcase_17 AC 20 ms
6,108 KB
testcase_18 AC 26 ms
6,372 KB
testcase_19 AC 25 ms
6,372 KB
testcase_20 AC 27 ms
6,372 KB
testcase_21 AC 24 ms
6,372 KB
testcase_22 AC 24 ms
6,372 KB
testcase_23 AC 22 ms
6,372 KB
testcase_24 AC 22 ms
6,372 KB
testcase_25 AC 22 ms
6,372 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 13 ms
5,052 KB
testcase_28 AC 11 ms
4,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const ll MOD=998244353;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> P(n),A(n);
  rep(i,n){
    cin>>P[i];
    A[P[i]]=i;
  }
  
  int m=A[0];
  int l=m,r=m;
  ll ans=1;
  for(int i=1;i<n;i++){
    if(A[i]<l) l=A[i];
    else if(A[i]>r) r=A[i];
    else ans=ans*(r-l-i+1)%MOD;
  }
  cout<<ans<<endl;

  return 0;
}
0