結果

問題 No.1709 Indistinguishable by MEX
ユーザー irumo8202irumo8202
提出日時 2022-01-29 17:21:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 109,064 KB
最終ジャッジ日時 2023-08-30 17:12:41
合計ジャッジ時間 4,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,960 KB
testcase_01 AC 77 ms
71,228 KB
testcase_02 AC 74 ms
71,200 KB
testcase_03 AC 75 ms
71,272 KB
testcase_04 AC 73 ms
71,060 KB
testcase_05 AC 75 ms
71,048 KB
testcase_06 AC 74 ms
71,148 KB
testcase_07 AC 73 ms
71,376 KB
testcase_08 AC 115 ms
101,832 KB
testcase_09 AC 108 ms
97,916 KB
testcase_10 AC 106 ms
95,736 KB
testcase_11 AC 101 ms
92,884 KB
testcase_12 AC 99 ms
91,176 KB
testcase_13 AC 115 ms
101,112 KB
testcase_14 AC 111 ms
98,056 KB
testcase_15 AC 114 ms
100,864 KB
testcase_16 AC 124 ms
108,388 KB
testcase_17 AC 122 ms
105,376 KB
testcase_18 AC 124 ms
108,840 KB
testcase_19 AC 122 ms
109,064 KB
testcase_20 AC 124 ms
108,880 KB
testcase_21 AC 127 ms
108,724 KB
testcase_22 AC 125 ms
108,872 KB
testcase_23 AC 127 ms
108,716 KB
testcase_24 AC 125 ms
108,756 KB
testcase_25 AC 124 ms
108,744 KB
testcase_26 AC 74 ms
71,336 KB
testcase_27 AC 100 ms
93,016 KB
testcase_28 AC 99 ms
90,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ind = [0] * N
for i in range(N):
    ind[P[i]] = i

ans = 1
l = r = ind[0]

for k in range(1, N):
    i = ind[k]
    nl, nr = min(l, i), max(r, i)
    if (l, r) == (nl, nr):
        ans *= r - l + 1 - k
        ans %= MOD
    l, r = nl, nr

print(ans)
0