AT_arc227_f.Erase and Raise
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is an integer sequence A=(0,0,…,0) of length N. The following operation is repeated as long as it can be performed.
- Choose a pair of integers (i,j) satisfying 1≤i<j≤∣A∣ and Ai=Aj.
- Remove Ai and Aj from the sequence.
- Add 1 to every element that was between Ai and Aj immediately before the removal.
Here, ∣A∣ denotes the length of the sequence A at that point.
Find the number, modulo 998244353, of possible sequences when no more operations can be performed. If the final sequences are the same, they are not distinguished even if the process of operations differs. A sequence of length 0 is also counted as one sequence.
有一个长度为 N 的整数序列 A=(0,0,…,0)。只要还能执行,就重复以下操作:
- 选择一对满足 1≤i<j≤∣A∣ 且 Ai=Aj 的整数 (i,j);
- 从序列中删除 Ai 和 Aj;
- 将删除前位于 Ai 与 Aj 之间的所有元素均加 1。
其中,∣A∣ 表示当前序列 A 的长度。
求当无法再执行任何操作时,可能得到的不同最终序列的个数(对 998244353 取模)。若两个最终序列完全相同,则无论操作过程是否不同,均视为同一种序列(即不区分操作路径)。空序列(长度为 0)也计为一种序列。
输入格式
The input is given from Standard Input in the following format:
N
输入从标准输入中按以下格式给出:
N
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
1
输出#1
1
输入#2
5
输出#2
3
输入#3
7
输出#3
8
输入#4
200000
输出#4
159211719
说明/提示
Sample 1 Explanation:
No operation can be performed, so there is one possible final sequence: (0).
Sample 2 Explanation:
There are three possible final sequences: (0), (1), (2).
Sample 3 Explanation:
Depending on the choices made during the operations, eight different sequences can be obtained.
Sample 4 Explanation:
Be sure to find the count modulo 998244353.
Constraints
- 1≤N≤2×105
- All input values are integers.
样例 1 解释:
无法执行任何操作,因此只存在一种可能的最终序列:(0)。
样例 2 解释:
存在三种可能的最终序列:(0)、(1)、(2)。
样例 3 解释:
根据操作过程中所作的选择,可得到八种不同的序列。
样例 4 解释:
请务必对答案取模 998244353。
约束条件
- 1≤N≤2×105
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?