結果

問題 No.1709 Indistinguishable by MEX
ユーザー brthyyjp
提出日時 2022-01-24 19:27:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 108,032 KB
最終ジャッジ日時 2024-12-14 19:19:51
合計ジャッジ時間 4,454 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
P = list(map(int, input().split()))
mod = 998244353

ptoi = [0]*n
for i, p in enumerate(P):
    ptoi[p] = i

ans = 1
l = ptoi[0]
r = ptoi[0]
for p in range(1, n):
    i = ptoi[p]
    nl, nr = min(l, i), max(r, i)
    if (l, r) == (nl, nr):
        ans *= (r-l+1-p)
        ans %= mod
    l, r = nl, nr
print(ans)
0