結果
問題 | No.1709 Indistinguishable by MEX |
ユーザー |
|
提出日時 | 2021-05-28 01:03:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 1,561 ms |
コンパイル使用メモリ | 168,972 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 16:56:52 |
合計ジャッジ時間 | 3,481 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#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 secondconst 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 ;}