AT_arc227_e.Shift and XOR Switches

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a length-NN sequence B=(B1,B2,…,BN)B=(B_1,B_2,\ldots,B_N) consisting of 00 and 11. Initially, B1=1B_1=1, and all other elements are 00.

There are MM switches, and the integer AiA_i is written on switch ii (1≤i≤M1 \le i \le M). When switch ii is pressed, using the state immediately before the operation, BjB_j is simultaneously changed as follows for every integer jj satisfying 1≤j≤N1 \le j \le 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 998244353998244353, of possible final sequences BB.

What is the bitwise XOR\mathrm{XOR} operation?

The bitwise XOR\mathrm{XOR} of non-negative integers AA and BB, denoted A⊕BA \oplus B, is defined as follows:

  • The digit in the 2k2^k's place (k≥0k \geq 0) of A⊕BA \oplus B, written in binary, is 11 if exactly one of the digits in the 2k2^k's place of AA and BB, written in binary, is 11, and 00 otherwise.

For example, 3⊕5=63 \oplus 5 = 6 (in binary: 011⊕101=110011 \oplus 101 = 110). In general, the bitwise XOR\mathrm{XOR} of kk non-negative integers p1,p2,p3,…,pkp_1, p_2, p_3, \dots, p_k is defined as (…((p1⊕p2)⊕p3)⊕⋯⊕pk)(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k), and it can be proved that this does not depend on the order of p1,p2,p3,…,pkp_1, p_2, p_3, \dots, p_k.

存在一个长度为 NN 的由 00 和 11 构成的序列 B=(B1,B2,…,BN)B=(B_1,B_2,\ldots,B_N)。初始时,B1=1B_1=1,其余所有元素均为 00。

共有 MM 个开关,第 ii 个开关(1≤i≤M1 \le i \le M)上写有一个整数 AiA_i。当按下开关 ii 时,根据操作前的当前状态,对每个满足 1≤j≤N1 \le j \le N 的整数 jj,同时更新 BjB_j 如下:

[
B_j \leftarrow \begin{cases} B_j \oplus B_{j-A_i} & (A_i < j),\ B_j & (j \le A_i) \end{cases}
]

每个开关可被按下零次或一次,且开关的按下顺序可以任意。

求最终可能得到的不同序列 BB 的个数(对 998244353998244353 取模)。

什么是按位 XOR\mathrm{XOR} 运算?

非负整数 AA 与 BB 的按位 XOR\mathrm{XOR}(记作 A⊕BA \oplus B)定义如下:

  • 将 A⊕BA \oplus B 写成二进制后,其 2k2^k 位(k≥0k \geq 0)上的数字为 11,当且仅当 AA 和 BB 的二进制表示中,2k2^k 位上的数字恰好有一个为 11;否则该位为 00。

例如,3⊕5=63 \oplus 5 = 6(二进制:011⊕101=110011 \oplus 101 = 110)。一般地,kk 个非负整数 p1,p2,p3,…,pkp_1, p_2, p_3, \dots, p_k 的按位 XOR\mathrm{XOR} 定义为 (…((p1⊕p2)⊕p3)⊕⋯⊕pk)(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k),且可以证明该结果与 p1,p2,p3,…,pkp_1, p_2, p_3, \dots, p_k 的运算顺序无关。

输入格式

The input is given from Standard Input in the following format:

NN MM
A1A_1 A2A_2 …\ldots AMA_M

输入从标准输入中按以下格式给出:

NN MM
A1A_1 A2A_2 …\ldots AMA_M

输出格式

Output the number, modulo 998244353998244353, of possible final sequences BB.

输出可能的最终序列 BB 的数量,对 998244353998244353 取模。

输入输出样例

  • 输入#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,0,0)
  • (1,0,1,0)(1,0,1,0)
  • (1,0,0,1)(1,0,0,1)
  • (1,0,1,1)(1,0,1,1)

Sample 2 Explanation:
There are two possible final sequences: (1,0)(1,0) and (1,1)(1,1).

Constraints

  • 2≤N≤2×1052 \le N \le 2 \times 10^5
  • 1≤M≤2×1051 \le M \le 2 \times 10^5
  • 1≤Ai<N1 \le A_i \lt N (1≤i≤M1 \le i \le M)
  • All input values are integers.

样例 1 解释:
共有四种可能的最终序列:

  • (1,0,0,0)(1,0,0,0)
  • (1,0,1,0)(1,0,1,0)
  • (1,0,0,1)(1,0,0,1)
  • (1,0,1,1)(1,0,1,1)

样例 2 解释:
共有两种可能的最终序列:(1,0)(1,0) 和 (1,1)(1,1)。

约束条件

  • 2≤N≤2×1052 \le N \le 2 \times 10^5
  • 1≤M≤2×1051 \le M \le 2 \times 10^5
  • 1≤Ai<N1 \le A_i \lt N(1≤i≤M1 \le i \le M)
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页