結果
問題 | No.1709 Indistinguishable by MEX |
ユーザー |
|
提出日時 | 2024-12-24 23:49:10 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 6,236 ms |
コンパイル使用メモリ | 307,340 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 23:53:11 |
合計ジャッジ時間 | 9,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using mint = modint998244353; int main() { int n; cin >> n; vector<int> pos(n); rep(i, n) { int x; cin >> x; pos[x] = i; } mint ans = 1; int l = n, r = -1; rep(i, n) { if (l <= pos[i] and pos[i] <= r) { ans *= r-l+1 - i; } else { l = min(l, pos[i]); r = max(r, pos[i]); } } cout << ans.val() << '\n'; return 0; }