AtCoder Grand Contest 058
翻译中…
Problem Statement
翻译中…
You are given a permutation $P=(P_1,P_2,\cdots,P_N)$ of $(1,2,\cdots,N)$.
翻译中…
You may perform the following operation zero or more times.
翻译中…
- Choose an integer
$i$($1 \leq i \leq N-1$). Let$v=\max(P_i,P_{i+1})$and replace the values of$P_i$and$P_{i+1}$with$v$.
翻译中…
How many sequences are there that $P$ can be after your operations? Find the count modulo $998244353$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 5000$$(P_1,P_2,\cdots,P_N)$is a permutation of$(1,2,\cdots,N)$.- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
P_1 P_2 \cdots P_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3
1 3 2
Output #1
4
The four sequences that $P$ can become are $(1,3,2)$, $(3,3,2)$, $(1,3,3)$, and $(3,3,3)$.
Input #2
4
2 1 3 4
Output #2
11
Input #3
10
4 9 6 3 8 10 1 2 7 5
Output #3
855
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。