結果

問題 No.1709 Indistinguishable by MEX
ユーザー tktk_snsn
提出日時 2021-10-16 15:32:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 29,992 KB
最終ジャッジ日時 2024-09-17 19:27:34
合計ジャッジ時間 6,732 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

ans = 1
cnt = 1
L = R = ptoi[0]
for i in range(1, N):
    p = ptoi[i]
    if p < L or R < p:
        L = min(L, p)
        R = max(R, p)
    else:
        ans *= (R - L + 1) - cnt
        ans %= mod
    cnt += 1


print(ans)
0