結果

問題 No.1709 Indistinguishable by MEX
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-24 19:27:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 108,160 KB
最終ジャッジ日時 2024-05-08 14:30:56
合計ジャッジ時間 4,199 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,712 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 36 ms
52,096 KB
testcase_04 AC 37 ms
51,968 KB
testcase_05 AC 42 ms
52,096 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 37 ms
52,096 KB
testcase_08 AC 84 ms
96,256 KB
testcase_09 AC 79 ms
91,264 KB
testcase_10 AC 75 ms
88,320 KB
testcase_11 AC 68 ms
84,608 KB
testcase_12 AC 66 ms
82,304 KB
testcase_13 AC 82 ms
96,128 KB
testcase_14 AC 80 ms
92,544 KB
testcase_15 AC 83 ms
95,872 KB
testcase_16 AC 94 ms
106,112 KB
testcase_17 AC 90 ms
101,632 KB
testcase_18 AC 102 ms
105,344 KB
testcase_19 AC 92 ms
105,088 KB
testcase_20 AC 94 ms
105,216 KB
testcase_21 AC 99 ms
108,160 KB
testcase_22 AC 96 ms
106,240 KB
testcase_23 AC 93 ms
105,728 KB
testcase_24 AC 95 ms
106,240 KB
testcase_25 AC 94 ms
105,472 KB
testcase_26 AC 38 ms
52,096 KB
testcase_27 AC 69 ms
84,096 KB
testcase_28 AC 65 ms
81,792 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