結果

問題 No.1709 Indistinguishable by MEX
ユーザー horitaka1999horitaka1999
提出日時 2021-11-07 00:34:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 139,820 KB
最終ジャッジ日時 2023-08-07 19:10:42
合計ジャッジ時間 7,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,644 KB
testcase_01 AC 88 ms
71,496 KB
testcase_02 AC 87 ms
71,444 KB
testcase_03 AC 88 ms
71,580 KB
testcase_04 AC 88 ms
71,608 KB
testcase_05 AC 89 ms
71,248 KB
testcase_06 AC 87 ms
71,680 KB
testcase_07 AC 89 ms
71,724 KB
testcase_08 AC 160 ms
124,416 KB
testcase_09 AC 147 ms
118,716 KB
testcase_10 AC 144 ms
113,896 KB
testcase_11 AC 135 ms
109,392 KB
testcase_12 AC 132 ms
105,972 KB
testcase_13 AC 153 ms
124,236 KB
testcase_14 AC 148 ms
118,920 KB
testcase_15 AC 156 ms
124,108 KB
testcase_16 AC 171 ms
139,448 KB
testcase_17 AC 162 ms
132,752 KB
testcase_18 AC 176 ms
139,680 KB
testcase_19 AC 176 ms
139,712 KB
testcase_20 AC 175 ms
139,592 KB
testcase_21 AC 172 ms
139,820 KB
testcase_22 AC 170 ms
139,728 KB
testcase_23 AC 168 ms
139,616 KB
testcase_24 AC 168 ms
139,784 KB
testcase_25 AC 168 ms
139,660 KB
testcase_26 AC 91 ms
71,612 KB
testcase_27 AC 134 ms
109,720 KB
testcase_28 AC 130 ms
105,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())                    
P = list(map(int,input().split()))
dic = defaultdict(int)
for i in range(N):
    dic[P[i]] = i
l = 0
r = 0
ans = 1
mod = 998244353
for x in range(N):
    if x == 0:
        l = dic[x]
        r = dic[x]
    else:
        index = dic[x]
        if l < index < r:
            ans *= (r-l+1-x)
            ans %= mod
        else:
            l = min(index,l)
            r = max(index,r)
print(ans)

0