异或匹配AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There are $N$ cards. The $i$-th card ($1\leq i\leq N$) has the integer $A_i$ written on it. Here, $0\leq A_i \leq 2^M-1$ holds.
For each integer $X=0,1,\ldots,2^M-1$, let $f(X)$ denote the answer to the following problem:
Consider forming some pairs of cards.
Each pair consists of two distinct cards, and the bitwise XOR of the integers written on those two cards must equal
$X$. The same card cannot be included in multiple pairs.Find the maximum number of pairs that can be formed under these conditions.
Output the following value:
[ \left(\sum_{X=0}^{2^M-1} f(X) \times 10 ^ X\right) \bmod 998244353 ]
What is the bitwise $\mathrm{XOR}$ operation The bitwise $\mathrm{XOR}$ of non-negative integers $A, B$, $A \oplus B$, is defined as follows. The digit at the $2^k$ ($k \geq 0$) place of $A \oplus B$ in binary representation is $1$ if exactly one of the digits at the $2^k$ place of $A$ and $B$ in binary representation is $1$, and $0$ otherwise. For example, $3 \oplus 5 = 6$ (in binary: $011 \oplus 101 = 110$). In general, the bitwise $\mathrm{XOR}$ of $k$ non-negative integers $p_1, p_2, p_3, \dots, p_k$ is defined as $(\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 $p_1, p_2, p_3, \dots, p_k$.
有 $N$ 张卡片。第 $i$ 张卡片($1\leq i\leq N$)上写有整数 $A_i$。其中满足 $0\leq A_i \leq 2^M-1$。
对于每个整数 $X=0,1,\ldots,2^M-1$,令 $f(X)$ 表示以下问题的答案:
考虑将一些卡片组成若干对。
每一对由两张不同的卡片组成,并且这两张卡片上所写整数的按位 XOR 必须等于
$X$。同一张卡片不能同时属于多个数对。求在满足上述条件的情况下,最多能组成多少对。
请输出以下值:
[ \left(\sum_{X=0}^{2^M-1} f(X) \times 10 ^ X\right) \bmod 998244353 ]
什么是按位 $\mathrm{XOR}$ 运算?
非负整数 $A,B$ 的按位 $\mathrm{XOR}$ $A \oplus B$ 定义如下:在二进制表示中,$A \oplus B$ 的 $2^k$($k \geq 0$)位,当且仅当 $A$ 和 $B$ 的 $2^k$ 位中恰好有一位为 $1$ 时为 $1$,否则为 $0$。
例如,$3 \oplus 5 = 6$(二进制表示为:$011 \oplus 101 = 110$)。一般来说,$k$ 个非负整数 $p_1, p_2, p_3, \dots, p_k$ 的按位 $\mathrm{XOR}$ 定义为 $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$,并且可以证明其结果与 $p_1, p_2, p_3, \dots, p_k$ 的排列顺序无关。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$2\leq N\leq 2\times 10^5$$1\leq M\leq 20$$0\leq A_i \leq 2^M-1$($1\leq i\leq N$)- All input values are integers.
$2\leq N\leq 2\times 10^5$$1\leq M\leq 20$$0\leq A_i \leq 2^M-1$($1\leq i\leq N$)- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N M
A_1 A_2 \ldots A_N
N M
A_1 A_2 \ldots A_NAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the following value:
请输出以下值:AI (CI翻译)
[ \left(\sum_{X=0}^{2^M-1} f(X) \times 10 ^ X\right) \bmod 998244353 ]
[ \left(\sum_{X=0}^{2^M-1} f(X) \times 10 ^ X\right) \bmod 998244353 ]AI (CI翻译)
样例
4 2
1 1 3 3
202
10 3
5 2 1 4 5 5 5 0 1 7
22332223
10 4
11 6 3 8 6 7 14 10 10 11
613668597
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。