結果
問題 | No.1709 Indistinguishable by MEX |
ユーザー |
![]() |
提出日時 | 2021-10-15 21:58:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 160 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 72,592 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-09-17 17:28:46 |
合計ジャッジ時間 | 3,832 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <iostream> #include <set> using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int n; cin >> n; int p[200005], r[200005]; for(int i = 0; i < n; i++){ cin >> p[i]; r[p[i]] = i; } set<int> st; st.insert(r[0]); ll ans = 1; for(int i = 1; i < n; i++){ if(r[i] > *st.begin() && r[i] < *st.rbegin()) ans = ans * (*st.rbegin() - *st.begin() - i + 1) % MOD; st.insert(r[i]); } cout << ans << endl; }