问题 B: Break Sequence

内存限制:256 MB 时间限制:4 S
题面:Markdown 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Given a sequence $a$ length $n$ and a set $S$ size $m$. Count the number of sequence $0=p_0<p_1<p_2<\cdots<p_k<p_{k+1}=n$ such that:
For any $0 \leq i \leq k, x \in S$ and $1 \leq j \leq n, \sum_{l=p_i+1}^{p_{i+1}}\left[a_l=j\right] \neq x$.

输入格式

Line $1$: Two integers $n,m$. 
Line $2$: $n$ integers, indicating sequence $a$. 
Line $3$: $m$ integers, indicating set $S$.

输出格式

Line $1$: An integer, the answer, modulo $998244353$.

输入样例 复制

5 1
1 2 3 1 3
2

输出样例 复制

11

数据范围与提示

$1\leq n\leq 2\times10^5$. $0\leq m\leq 10$. $1\leq a_i\leq n$. All integers in set $S$ are between $1$ and $n$.