結果
問題 | No.1709 Indistinguishable by MEX |
ユーザー | 蜜蜂 |
提出日時 | 2021-10-15 22:02:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 1,215 bytes |
コンパイル時間 | 3,264 ms |
コンパイル使用メモリ | 233,680 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 17:30:23 |
合計ジャッジ時間 | 4,748 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
//g++ 2.cpp -std=c++14 -O2 -I . #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; using vvld = vector<vld>; #define fi first #define se second #define pb push_back #define pq_big(T) priority_queue<T,vector<T>,less<T>> #define pq_small(T) priority_queue<T,vector<T>,greater<T>> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) constexpr ll mod = 998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector<pair<int,int>> P; rep(i,0,n){ int p; cin>>p; P.emplace_back(p,i); } sort(all(P)); ll ans=1; int left=P[0].se,right=P[0].se; rep(i,1,n){ int ind=P[i].se; if(left<ind&&ind<right){ ans*=(right-left+1-i); ans%=mod; } else{ if(ind<left){ left=ind; } else{ right=ind; } } } cout<<ans<<endl; }