結果

問題 No.1709 Indistinguishable by MEX
ユーザー 👑 tamatotamato
提出日時 2021-10-15 21:52:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 81,964 KB
実行使用メモリ 131,768 KB
最終ジャッジ日時 2023-10-17 20:15:05
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,712 KB
testcase_01 AC 38 ms
53,712 KB
testcase_02 AC 38 ms
53,712 KB
testcase_03 AC 39 ms
53,712 KB
testcase_04 AC 38 ms
53,712 KB
testcase_05 AC 38 ms
53,712 KB
testcase_06 AC 38 ms
53,712 KB
testcase_07 AC 39 ms
53,712 KB
testcase_08 AC 113 ms
119,600 KB
testcase_09 AC 101 ms
112,744 KB
testcase_10 AC 97 ms
108,144 KB
testcase_11 AC 86 ms
101,628 KB
testcase_12 AC 82 ms
98,040 KB
testcase_13 AC 106 ms
119,288 KB
testcase_14 AC 98 ms
113,172 KB
testcase_15 AC 105 ms
118,944 KB
testcase_16 AC 128 ms
127,076 KB
testcase_17 AC 124 ms
131,768 KB
testcase_18 AC 135 ms
122,440 KB
testcase_19 AC 132 ms
122,440 KB
testcase_20 AC 136 ms
122,440 KB
testcase_21 AC 134 ms
122,440 KB
testcase_22 AC 126 ms
122,440 KB
testcase_23 AC 119 ms
122,440 KB
testcase_24 AC 119 ms
122,440 KB
testcase_25 AC 118 ms
122,440 KB
testcase_26 AC 37 ms
53,712 KB
testcase_27 AC 80 ms
101,756 KB
testcase_28 AC 77 ms
98,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    P = list(map(int, input().split()))

    idx = {p: i for i, p in enumerate(P)}
    i0 = idx[0]
    l = r = i0
    ans = 1
    for p in range(1, N):
        i = idx[p]
        if i < l:
            l = i
        elif i > r:
            r = i
        else:
            ans = (ans * (r - l + 1 - p))%mod
    print(ans)


if __name__ == '__main__':
    main()
0