結果

問題 No.1709 Indistinguishable by MEX
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-12-05 10:51:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 265 bytes
コンパイル時間 1,128 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 30,124 KB
最終ジャッジ日時 2023-09-21 13:24:30
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,724 KB
testcase_01 AC 14 ms
7,768 KB
testcase_02 AC 14 ms
7,804 KB
testcase_03 AC 14 ms
7,744 KB
testcase_04 AC 14 ms
7,752 KB
testcase_05 AC 14 ms
7,860 KB
testcase_06 AC 14 ms
7,864 KB
testcase_07 AC 15 ms
7,748 KB
testcase_08 AC 173 ms
27,048 KB
testcase_09 AC 147 ms
23,520 KB
testcase_10 AC 136 ms
23,684 KB
testcase_11 AC 115 ms
20,836 KB
testcase_12 AC 111 ms
20,060 KB
testcase_13 AC 160 ms
25,532 KB
testcase_14 AC 144 ms
24,068 KB
testcase_15 AC 153 ms
25,024 KB
testcase_16 AC 197 ms
30,124 KB
testcase_17 AC 187 ms
29,740 KB
testcase_18 AC 212 ms
29,812 KB
testcase_19 AC 213 ms
29,856 KB
testcase_20 AC 224 ms
29,804 KB
testcase_21 AC 208 ms
29,820 KB
testcase_22 AC 209 ms
29,852 KB
testcase_23 AC 266 ms
29,976 KB
testcase_24 AC 265 ms
29,872 KB
testcase_25 AC 260 ms
29,980 KB
testcase_26 AC 14 ms
7,720 KB
testcase_27 AC 146 ms
20,872 KB
testcase_28 AC 136 ms
19,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())
p = list(map(int, input().split()))
q = [-1] * n
for i in range(n):
	q[p[i]] = i
l, r = n, -1
ans = 1
for i in range(n):
	if l <= q[i] <= r:
		ans *= r - l + 1 - i
		ans %= mod
	else:
		l = min(l, q[i])
		r = max(r, q[i])
print(ans)
0