結果

問題 No.1709 Indistinguishable by MEX
ユーザー shotoyooshotoyoo
提出日時 2021-10-15 22:26:52
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 110,152 KB
最終ジャッジ日時 2023-10-17 20:28:11
合計ジャッジ時間 3,626 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,444 KB
testcase_01 AC 38 ms
53,444 KB
testcase_02 AC 38 ms
53,444 KB
testcase_03 AC 40 ms
53,444 KB
testcase_04 AC 37 ms
53,444 KB
testcase_05 AC 37 ms
53,444 KB
testcase_06 AC 37 ms
53,444 KB
testcase_07 AC 38 ms
53,444 KB
testcase_08 AC 101 ms
110,152 KB
testcase_09 AC 97 ms
109,348 KB
testcase_10 AC 85 ms
101,380 KB
testcase_11 AC 78 ms
96,096 KB
testcase_12 AC 75 ms
93,372 KB
testcase_13 AC 101 ms
108,288 KB
testcase_14 AC 99 ms
108,064 KB
testcase_15 AC 101 ms
109,260 KB
testcase_16 AC 111 ms
107,736 KB
testcase_17 AC 105 ms
106,064 KB
testcase_18 AC 109 ms
109,228 KB
testcase_19 AC 108 ms
109,228 KB
testcase_20 AC 108 ms
109,228 KB
testcase_21 AC 111 ms
107,908 KB
testcase_22 AC 110 ms
107,908 KB
testcase_23 AC 112 ms
107,644 KB
testcase_24 AC 111 ms
107,644 KB
testcase_25 AC 111 ms
107,908 KB
testcase_26 AC 37 ms
53,444 KB
testcase_27 AC 75 ms
96,264 KB
testcase_28 AC 73 ms
93,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
# sys.setrecursionlimit(3*10**5+10)

n = int(input())
p = list(map(int, input().split()))
index = [0]*n
for i,v in enumerate(p):
    index[v] = i
M = 998244353
lr = []
inf = 10**9
mm = inf
MM = -1
ans = 1
for i in range(n):
    ind = index[i]
    mm = min(mm, ind)
    MM = max(MM, ind)
    lr.append((mm,MM))
mm = inf
MM = -1
for i in range(n):
    l,r = lr[i]
    if (mm, MM) == (l,r):
        ans *= (MM - mm + 1) - i
        ans %= M
    mm = min(mm, l)
    MM = max(MM, r)
print(ans%M)
0