結果

問題 No.1709 Indistinguishable by MEX
ユーザー chineristACchineristAC
提出日時 2021-05-25 22:56:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 107,896 KB
最終ジャッジ日時 2023-10-17 19:43:22
合計ジャッジ時間 5,322 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
56,160 KB
testcase_01 AC 45 ms
56,160 KB
testcase_02 AC 45 ms
56,160 KB
testcase_03 AC 45 ms
56,160 KB
testcase_04 AC 46 ms
56,160 KB
testcase_05 AC 46 ms
56,160 KB
testcase_06 AC 46 ms
56,160 KB
testcase_07 AC 46 ms
56,160 KB
testcase_08 AC 89 ms
98,736 KB
testcase_09 AC 82 ms
94,484 KB
testcase_10 AC 79 ms
92,080 KB
testcase_11 AC 74 ms
87,256 KB
testcase_12 AC 73 ms
85,440 KB
testcase_13 AC 87 ms
98,596 KB
testcase_14 AC 83 ms
95,064 KB
testcase_15 AC 88 ms
98,252 KB
testcase_16 AC 103 ms
107,896 KB
testcase_17 AC 99 ms
104,588 KB
testcase_18 AC 102 ms
106,472 KB
testcase_19 AC 102 ms
106,472 KB
testcase_20 AC 102 ms
106,472 KB
testcase_21 AC 102 ms
106,472 KB
testcase_22 AC 102 ms
106,472 KB
testcase_23 AC 102 ms
106,472 KB
testcase_24 AC 102 ms
106,472 KB
testcase_25 AC 101 ms
106,472 KB
testcase_26 AC 45 ms
56,160 KB
testcase_27 AC 74 ms
89,480 KB
testcase_28 AC 71 ms
85,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 998244353

def solve(N,P):
    pos = [-1 for i in range(N)]
    for i in range(N):
        pos[P[i]] = i

    assert -1 not in pos

    L,R = N,-1
    res = 1
    for i in range(N):
        if L <= pos[i] <= R:
            res *= R-L+1 - i
            res %= mod
        else:
            L = min(pos[i],L)
            R = max(pos[i],R)

    return res

N = int(input())
P = li()
print(solve(N,P))
0