結果
問題 |
No.1709 Indistinguishable by MEX
|
ユーザー |
|
提出日時 | 2024-10-10 20:50:38 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 12,640 ms |
コンパイル使用メモリ | 404,968 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-10-10 20:50:54 |
合計ジャッジ時間 | 15,174 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
use proconio::input; fn main() { input! { n:usize, p:[usize;n], } const MOD: usize = 998244353; let mut poss = vec![0; n]; for i in 0..n { poss[p[i]] = i; } let mut ans = 1; let mut l = poss[0]; let mut r = poss[0]; for i in 1..n { if l <= poss[i] && poss[i] <= r { ans *= r - l + 1 - i; ans %= MOD; } else { l = l.min(poss[i]); r = r.max(poss[i]); } } println!("{}", ans); }