結果

問題 No.1709 Indistinguishable by MEX
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-24 19:27:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,484 KB
実行使用メモリ 108,888 KB
最終ジャッジ日時 2023-08-21 09:13:40
合計ジャッジ時間 5,415 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,412 KB
testcase_01 AC 74 ms
71,204 KB
testcase_02 AC 71 ms
71,088 KB
testcase_03 AC 71 ms
71,264 KB
testcase_04 AC 71 ms
71,224 KB
testcase_05 AC 71 ms
71,220 KB
testcase_06 AC 71 ms
71,152 KB
testcase_07 AC 71 ms
71,224 KB
testcase_08 AC 115 ms
101,500 KB
testcase_09 AC 108 ms
97,916 KB
testcase_10 AC 106 ms
95,648 KB
testcase_11 AC 102 ms
92,868 KB
testcase_12 AC 98 ms
91,112 KB
testcase_13 AC 114 ms
101,116 KB
testcase_14 AC 111 ms
98,248 KB
testcase_15 AC 115 ms
101,032 KB
testcase_16 AC 124 ms
108,580 KB
testcase_17 AC 120 ms
105,116 KB
testcase_18 AC 125 ms
108,788 KB
testcase_19 AC 123 ms
108,844 KB
testcase_20 AC 122 ms
108,572 KB
testcase_21 AC 125 ms
108,772 KB
testcase_22 AC 122 ms
108,888 KB
testcase_23 AC 121 ms
108,572 KB
testcase_24 AC 122 ms
108,848 KB
testcase_25 AC 122 ms
108,852 KB
testcase_26 AC 71 ms
71,240 KB
testcase_27 AC 97 ms
92,940 KB
testcase_28 AC 94 ms
90,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

ans = 1
l = ptoi[0]
r = ptoi[0]
for p in range(1, n):
    i = ptoi[p]
    nl, nr = min(l, i), max(r, i)
    if (l, r) == (nl, nr):
        ans *= (r-l+1-p)
        ans %= mod
    l, r = nl, nr
print(ans)
0