結果

問題 No.1709 Indistinguishable by MEX
ユーザー tktk_snsntktk_snsn
提出日時 2021-10-16 15:32:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 32,032 KB
最終ジャッジ日時 2023-10-17 22:13:17
合計ジャッジ時間 6,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,076 KB
testcase_01 AC 29 ms
10,076 KB
testcase_02 AC 29 ms
10,076 KB
testcase_03 AC 29 ms
10,076 KB
testcase_04 AC 29 ms
10,076 KB
testcase_05 AC 29 ms
10,076 KB
testcase_06 AC 28 ms
10,076 KB
testcase_07 AC 29 ms
10,076 KB
testcase_08 AC 240 ms
28,952 KB
testcase_09 AC 202 ms
25,524 KB
testcase_10 AC 193 ms
25,596 KB
testcase_11 AC 161 ms
22,812 KB
testcase_12 AC 160 ms
21,956 KB
testcase_13 AC 208 ms
27,548 KB
testcase_14 AC 194 ms
25,880 KB
testcase_15 AC 217 ms
26,908 KB
testcase_16 AC 262 ms
32,032 KB
testcase_17 AC 243 ms
31,576 KB
testcase_18 AC 285 ms
31,828 KB
testcase_19 AC 311 ms
31,828 KB
testcase_20 AC 292 ms
31,828 KB
testcase_21 AC 278 ms
31,828 KB
testcase_22 AC 277 ms
31,828 KB
testcase_23 AC 310 ms
31,828 KB
testcase_24 AC 316 ms
31,828 KB
testcase_25 AC 319 ms
31,828 KB
testcase_26 AC 29 ms
10,076 KB
testcase_27 AC 184 ms
22,880 KB
testcase_28 AC 168 ms
21,748 KB
権限があれば一括ダウンロードができます

ソースコード

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