AT_arc227_e.Shift and XOR Switches
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a length-N sequence B=(B1,B2,…,BN) consisting of 0 and 1. Initially, B1=1, and all other elements are 0.
There are M switches, and the integer Ai is written on switch i (1≤i≤M). When switch i is pressed, using the state immediately before the operation, Bj is simultaneously changed as follows for every integer j satisfying 1≤j≤N:
\[ B_j \leftarrow \begin{cases} B_j \oplus B_{j-A_i} & (A_i \lt j),\\ B_j & (j \le A_i) \end{cases} \]
Each switch can be pressed zero times or once, and the switches may be pressed in any order.
Find the number, modulo 998244353, of possible final sequences B.
What is the bitwise XOR operation?
The bitwise XOR of non-negative integers A and B, denoted A⊕B, is defined as follows:
- The digit in the 2k's place (k≥0) of A⊕B, written in binary, is 1 if exactly one of the digits in the 2k's place of A and B, written in binary, is 1, and 0 otherwise.
For example, 3⊕5=6 (in binary: 011⊕101=110). In general, the bitwise XOR of k non-negative integers p1,p2,p3,…,pk is defined as (…((p1⊕p2)⊕p3)⊕⋯⊕pk), and it can be proved that this does not depend on the order of p1,p2,p3,…,pk.
存在一个长度为 N 的由 0 和 1 构成的序列 B=(B1,B2,…,BN)。初始时,B1=1,其余所有元素均为 0。
共有 M 个开关,第 i 个开关(1≤i≤M)上写有一个整数 Ai。当按下开关 i 时,根据操作前的当前状态,对每个满足 1≤j≤N 的整数 j,同时更新 Bj 如下:
[
B_j \leftarrow \begin{cases} B_j \oplus B_{j-A_i} & (A_i < j),\ B_j & (j \le A_i) \end{cases}
]
每个开关可被按下零次或一次,且开关的按下顺序可以任意。
求最终可能得到的不同序列 B 的个数(对 998244353 取模)。
什么是按位 XOR 运算?
非负整数 A 与 B 的按位 XOR(记作 A⊕B)定义如下:
- 将 A⊕B 写成二进制后,其 2k 位(k≥0)上的数字为 1,当且仅当 A 和 B 的二进制表示中,2k 位上的数字恰好有一个为 1;否则该位为 0。
例如,3⊕5=6(二进制:011⊕101=110)。一般地,k 个非负整数 p1,p2,p3,…,pk 的按位 XOR 定义为 (…((p1⊕p2)⊕p3)⊕⋯⊕pk),且可以证明该结果与 p1,p2,p3,…,pk 的运算顺序无关。
输入格式
The input is given from Standard Input in the following format:
N M
A1 A2 … AM
输入从标准输入中按以下格式给出:
N M
A1 A2 … AM
输出格式
Output the number, modulo 998244353, of possible final sequences B.
输出可能的最终序列 B 的数量,对 998244353 取模。
输入输出样例
输入#1
4 2 2 3
输出#1
4
输入#2
2 1 1
输出#2
2
输入#3
96 30 56 6 46 18 9 38 20 25 18 44 46 71 44 65 42 20 38 25 9 95 18 65 71 9 95 65 9 42 65 6
输出#3
384912
说明/提示
Sample 1 Explanation:
There are four possible final sequences:
- (1,0,0,0)
- (1,0,1,0)
- (1,0,0,1)
- (1,0,1,1)
Sample 2 Explanation:
There are two possible final sequences: (1,0) and (1,1).
Constraints
- 2≤N≤2×105
- 1≤M≤2×105
- 1≤Ai<N (1≤i≤M)
- All input values are integers.
样例 1 解释:
共有四种可能的最终序列:
- (1,0,0,0)
- (1,0,1,0)
- (1,0,0,1)
- (1,0,1,1)
样例 2 解释:
共有两种可能的最终序列:(1,0) 和 (1,1)。
约束条件
- 2≤N≤2×105
- 1≤M≤2×105
- 1≤Ai<N(1≤i≤M)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?