結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,156 KB
testcase_01 AC 75 ms
71,348 KB
testcase_02 AC 75 ms
70,968 KB
testcase_03 AC 73 ms
71,192 KB
testcase_04 AC 75 ms
71,348 KB
testcase_05 AC 74 ms
71,220 KB
testcase_06 AC 74 ms
71,328 KB
testcase_07 AC 73 ms
71,332 KB
testcase_08 AC 118 ms
101,760 KB
testcase_09 AC 108 ms
98,156 KB
testcase_10 AC 105 ms
95,852 KB
testcase_11 AC 101 ms
92,892 KB
testcase_12 AC 100 ms
90,940 KB
testcase_13 AC 114 ms
101,112 KB
testcase_14 AC 113 ms
98,328 KB
testcase_15 AC 119 ms
100,952 KB
testcase_16 AC 126 ms
108,540 KB
testcase_17 AC 122 ms
105,436 KB
testcase_18 AC 125 ms
108,720 KB
testcase_19 AC 125 ms
108,764 KB
testcase_20 AC 126 ms
108,808 KB
testcase_21 AC 131 ms
108,668 KB
testcase_22 AC 126 ms
108,832 KB
testcase_23 AC 126 ms
108,844 KB
testcase_24 AC 126 ms
108,960 KB
testcase_25 AC 126 ms
108,704 KB
testcase_26 AC 74 ms
71,136 KB
testcase_27 AC 101 ms
92,840 KB
testcase_28 AC 98 ms
91,020 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