結果

問題 No.1709 Indistinguishable by MEX
ユーザー IgrmiIgrmi
提出日時 2021-10-15 22:28:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 105,080 KB
最終ジャッジ日時 2023-10-17 20:29:19
合計ジャッジ時間 3,675 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,520 KB
testcase_01 AC 41 ms
53,520 KB
testcase_02 AC 39 ms
53,520 KB
testcase_03 AC 39 ms
53,520 KB
testcase_04 AC 38 ms
53,520 KB
testcase_05 AC 38 ms
53,520 KB
testcase_06 AC 38 ms
53,520 KB
testcase_07 AC 36 ms
53,520 KB
testcase_08 AC 79 ms
95,436 KB
testcase_09 AC 73 ms
91,920 KB
testcase_10 AC 70 ms
87,468 KB
testcase_11 AC 66 ms
84,692 KB
testcase_12 AC 64 ms
82,876 KB
testcase_13 AC 77 ms
95,084 KB
testcase_14 AC 75 ms
92,200 KB
testcase_15 AC 77 ms
94,936 KB
testcase_16 AC 90 ms
104,816 KB
testcase_17 AC 84 ms
100,828 KB
testcase_18 AC 88 ms
104,612 KB
testcase_19 AC 88 ms
104,612 KB
testcase_20 AC 88 ms
104,612 KB
testcase_21 AC 89 ms
105,080 KB
testcase_22 AC 89 ms
105,068 KB
testcase_23 AC 87 ms
104,548 KB
testcase_24 AC 87 ms
104,788 KB
testcase_25 AC 87 ms
104,548 KB
testcase_26 AC 38 ms
53,520 KB
testcase_27 AC 65 ms
84,848 KB
testcase_28 AC 61 ms
82,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
N = int(input())
P = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()
PRev = [-1] * N
for i in range(N): PRev[P[i]] = i
L, R = PRev[0], PRev[1]
if L > R: L, R = R, L
Ans = 1
for i in range(2, N):
    Pos = PRev[i]
    if L <= Pos and Pos <= R:
        Ans *= R - L - i + 1
        Ans %= MOD
    elif Pos < L: L = Pos
    else: R = Pos
print(Ans)
0