AtCoder Regular Contest 125
D
Unique Subsequence
AtCoder
⌀ 2187
原题
← CE →
翻译中…

Problem Statement

翻译中…

Given is a sequence of $N$ integers $A_1,A_2,\cdots,A_N$.

翻译中…

Find the number of non-empty subsequences $s$ of $A$ satisfying the following condition, modulo $998244353$.

翻译中…
  • There is only one way to extract $s$ from $A$. Formally, there uniquely exists a sequence of indices $1 \leq idx(1)<idx(2)<\cdots<idx(k) \leq N$ such that $A_{idx(i)}=s_i$ ($1 \leq i \leq k$), where $s=(s_1,s_2,\cdots,s_k)$.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i \leq N$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3
1 2 1
Output #1
5
The following five subsequences satisfy the condition. - $(1,1)$ - $(1,2)$ - $(1,2,1)$ - $(2)$ - $(2,1)$ The subsequence $(1)$ does not satisfy the condition since there are two ways to extract it.
Input #2
4
4 2 1 3
Output #2
15
Input #3
12
1 2 3 6 9 2 3 3 9 6 1 6
Output #3
1178
题目信息
题号
arc125_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。