結果

問題 No.1709 Indistinguishable by MEX
ユーザー bonKotsubonKotsu
提出日時 2022-07-23 15:19:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 3,965 ms
コンパイル使用メモリ 260,000 KB
実行使用メモリ 5,568 KB
最終ジャッジ日時 2023-09-18 12:44:35
合計ジャッジ時間 6,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 48 ms
4,948 KB
testcase_09 AC 39 ms
4,632 KB
testcase_10 AC 38 ms
4,672 KB
testcase_11 AC 30 ms
4,508 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 44 ms
4,896 KB
testcase_14 AC 41 ms
4,672 KB
testcase_15 AC 43 ms
5,208 KB
testcase_16 AC 56 ms
5,152 KB
testcase_17 AC 52 ms
5,176 KB
testcase_18 AC 61 ms
5,504 KB
testcase_19 AC 59 ms
5,496 KB
testcase_20 AC 59 ms
5,520 KB
testcase_21 AC 58 ms
5,432 KB
testcase_22 AC 59 ms
5,468 KB
testcase_23 AC 58 ms
5,568 KB
testcase_24 AC 58 ms
5,500 KB
testcase_25 AC 58 ms
5,464 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 31 ms
4,408 KB
testcase_28 AC 29 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };

using mint = modint998244353;
int main() {
  int n;
  cin >> n;
  const int INF = 1001001001;
  vector<int> pos(n), l(n, INF), r(n, -1);
  rep(i,n) {
    int p;
    cin >> p;
    pos[p] = i;
  }
  rep(i,n) {
    chmin(l[i], pos[i]);
    chmax(r[i], pos[i]);
    if (i > 0) {
      chmin(l[i], l[i-1]);
      chmax(r[i], r[i-1]);
    }
  }
  mint ans = 1;
  for (int i = 1; i < n; i++) {
    if (l[i-1] == l[i] && r[i-1] == r[i]) {
      ans *= r[i]-l[i]+1-i;
    } 
  }
  cout << ans.val() << endl;

  return 0;
}
0