F - Many Xor Optimization Problems Editorial /

Time Limit: 8 sec / Memory Limit: 1024 MB

配点 : 10001000

問題文

PCT 君は以下の問題を作りました。

Xor Optimization Problem

長さ NN の非負整数列 A1,A2,...,ANA_1,A_2,...,A_N が与えられる。AA の要素を好きな個数選ぶとき、選んだ値の XOR\mathrm{XOR} が取りうる最大値はいくらか?

この問題は、Nyaan さんにとっては簡単だったため PCT 君は以下のように改題しました。

Many Xor Optimization Problems

長さ NN かつ全ての要素が 00 以上 2M12^M-1 以下である整数列は 2NM2^{NM} 通り存在しますが、その全てに対して Xor Optimization Problem を解いた時の解の総和を 998244353998244353 で割ったあまりを求めてください。

Many Xor Optimization Problems を解いてください。

XOR\mathrm{XOR} とは

非負整数 A,BA, B のビット単位 XOR\mathrm{XOR}ABA \oplus B は、以下のように定義されます。

  • ABA \oplus B を二進表記した際の 2k2^k (k0k \geq 0) の位の数は、A,BA, B を二進表記した際の 2k2^k の位の数のうち一方のみが 11 であれば 11、そうでなければ 00 である。
例えば、35=63 \oplus 5 = 6 となります (二進表記すると: 011101=110011 \oplus 101 = 110)。
一般に kk 個の非負整数 p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k のビット単位 XOR\mathrm{XOR}(((p1p2)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 の順番によらないことが証明できます。

制約

  • 1N,M2500001 \le N,M \le 250000
  • 入力は全て整数である。

入力

入力は以下の形式で標準入力から与えられます。

NN MM

出力

答えを出力してください。


入力例 1Copy

Copy
2 1

出力例 1Copy

Copy
3

長さが 22 かつ全ての要素が 00 以上 11 以下である整数列全てに対して Xor Optimization Problem を解きます。

  • A=(0,0)A=(0,0) の時の解は 00
  • A=(0,1)A=(0,1) の時の解は 11
  • A=(1,0)A=(1,0) の時の解は 11
  • A=(1,1)A=(1,1) の時の解は 11

よって、0+1+1+1=30+1+1+1=3 が解となります。


入力例 2Copy

Copy
3 4

出力例 2Copy

Copy
52290

入力例 3Copy

Copy
1234 5678

出力例 3Copy

Copy
495502261

Score : 10001000 points

Problem Statement

PCT made the following problem.

Xor Optimization Problem

You are given a sequence of non-negative integers of length NN: A1,A2,...,ANA_1,A_2,...,A_N. When it is allowed to choose any number of elements in AA, what is the maximum possible XOR\mathrm{XOR} of the chosen values?

Nyaan thought it was too easy and revised it to the following.

Many Xor Optimization Problems

There are 2NM2^{NM} sequences of length NN consisting of integers between 00 and 2M12^M-1. Find the sum, modulo 998244353998244353, of the answers to Xor Optimization Problem for all those sequences.

Solve Many Xor Optimization Problems.

What is bitwise XOR\mathrm{XOR}?

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

  • When ABA \oplus B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if exactly one of AA and BB is 11, and 00 otherwise.
For example, we have 35=63 \oplus 5 = 6 (in base two: 011101=110011 \oplus 101 = 110).
Generally, 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 (((p1p2)p3)pk)(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k). We can prove that this value does not depend on the order of p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k.

Constraints

  • 1N,M2500001 \le N,M \le 250000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the answer.


Sample Input 1Copy

Copy
2 1

Sample Output 1Copy

Copy
3

We are to solve Xor Optimization Problem for all sequences of length 22 consisting of integers between 00 and 11.

  • The answer for A=(0,0)A=(0,0) is 00.
  • The answer for A=(0,1)A=(0,1) is 11.
  • The answer for A=(1,0)A=(1,0) is 11.
  • The answer for A=(1,1)A=(1,1) is 11.

Thus, the final answer is 0+1+1+1=30+1+1+1=3.


Sample Input 2Copy

Copy
3 4

Sample Output 2Copy

Copy
52290

Sample Input 3Copy

Copy
1234 5678

Sample Output 3Copy

Copy
495502261


2025-04-15 (Tue)
05:19:04 +00:00