結果

問題 No.1709 Indistinguishable by MEX
ユーザー tassei903tassei903
提出日時 2021-10-15 22:03:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 107,596 KB
最終ジャッジ日時 2023-10-17 20:19:41
合計ジャッジ時間 3,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,436 KB
testcase_01 AC 37 ms
53,436 KB
testcase_02 AC 38 ms
53,436 KB
testcase_03 AC 37 ms
53,436 KB
testcase_04 AC 38 ms
53,436 KB
testcase_05 AC 41 ms
53,436 KB
testcase_06 AC 38 ms
53,436 KB
testcase_07 AC 38 ms
53,436 KB
testcase_08 AC 83 ms
97,596 KB
testcase_09 AC 74 ms
92,028 KB
testcase_10 AC 72 ms
89,632 KB
testcase_11 AC 67 ms
84,812 KB
testcase_12 AC 65 ms
82,996 KB
testcase_13 AC 81 ms
97,128 KB
testcase_14 AC 78 ms
94,252 KB
testcase_15 AC 80 ms
96,992 KB
testcase_16 AC 91 ms
105,828 KB
testcase_17 AC 88 ms
101,396 KB
testcase_18 AC 88 ms
105,100 KB
testcase_19 AC 90 ms
105,096 KB
testcase_20 AC 88 ms
105,108 KB
testcase_21 AC 95 ms
107,596 KB
testcase_22 AC 95 ms
107,596 KB
testcase_23 AC 92 ms
106,348 KB
testcase_24 AC 92 ms
106,348 KB
testcase_25 AC 91 ms
105,924 KB
testcase_26 AC 37 ms
53,436 KB
testcase_27 AC 67 ms
85,044 KB
testcase_28 AC 64 ms
83,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n = ni()
l = n
r = -1
ans = 1
p = na()
q = [-1]*n
mod = 998244353
for i in range(n):
    q[p[i]] = i

for i in range(n):
    ans *= max([1,r-l-i][l<=q[i]<r],1)
    ans %= mod
    r = max(q[i]+1,r)
    l = min(q[i], l)
print(ans)
0