#P17300. [ICPC 2026 Xi'an I] Transform

    ID: 17191 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>ICPC2026省赛/邀请赛西安

[ICPC 2026 Xi'an I] Transform

题目描述

Yuki has a multiset S={s1,…,sn}S = \{s_1, \dots, s_n\} of size nn and an integer kk.

Yuki defines a transformation as follows:

  • Choose a subset S′S' of SS (where S′S' can be an empty set), remove S′S' from SS, and add the mex⁡∗\operatorname{mex}^\ast of S′S' to SS.

Now, Yuki wants to perform several transformations such that SS becomes {k}\{k\}. You need to help Yuki find the minimum number of transformations required to make SS equal to {k}\{k\}. Since the answer can be very large, you only need to output the answer modulo 998244353998244353.

It can be proven that there always exists at least one sequence of operations that can transform SS into {k}\{k\}.

∗^\ast: The mex⁡\operatorname{mex} of a multiset is the smallest non-negative integer that does not appear in the multiset. For example, mex⁡{0,1,2}=3\operatorname{mex}\{0,1,2\} = 3, mex⁡{1,0,3,1}=2\operatorname{mex}\{1,0,3,1\} = 2, and mex⁡∅=0\operatorname{mex} \varnothing = 0.

输入格式

This problem contains multiple test cases.

The first line contains a positive integer tt (1≤t≤105)(1 \le t \le 10^5), representing the number of test cases.

For each test case:

  • The first line contains two integers n,kn, k (1≤n≤5⋅105, 0≤k≤109)(1 \le n \le 5\cdot10^5,\ 0 \le k \le 10^9).
  • The second line contains nn integers s1,…,sns_1, \dots, s_n (0≤si≤109)(0 \le s_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 5⋅1055\cdot 10^5.

输出格式

For each test case, output a single line containing an integer representing the minimum number of transformations required to make SS equal to {k}\{k\}, modulo 998244353998244353.

6
1 2
1
1 4
4
3 3
0 2 2
4 2
1 0 3 2
4 3
2 1 0 2
3 52
20 2 6
2
0
3
2
1
262875292

提示

For the 1st test case:

  • Yuki can choose S′=∅S' = \varnothing in the 1st transformation, making S={0,1}S = \{0,1\}, and then choose S′={0,1}S' = \{0,1\} in the 2nd transformation, making S={2}S = \{2\}.
  • It can be proven that no sequence of operations with fewer transformations exists, so the answer is 22.

For the 2nd test case:

  • Yuki does not need to perform any transformations to make S={4}S = \{4\}, so the answer is 00.

For the 3rd test case:

  • Yuki can choose S′=∅S' = \varnothing in the 1st transformation, making S={0,0,2,2}S = \{0,0,2,2\}, choose S′={0,2}S' = \{0,2\} in the 2nd transformation, making S={0,1,2}S = \{0,1,2\}, and then choose S′={0,1,2}S' = \{0,1,2\} in the 3rd transformation, making S={3}S = \{3\}.
  • It can be proven that no sequence of operations with fewer transformations exists, so the answer is 33.

For the 4th test case:

  • Yuki can choose S′={2,3}S' = \{2,3\} in the 1st transformation, making S={0,0,1}S = \{0,0,1\}, and then choose S′={0,0,1}S' = \{0,0,1\} in the 2nd transformation, making S={2}S = \{2\}.
  • It can be proven that no sequence of operations with fewer transformations exists, so the answer is 22.

For the 5th test case:

  • Yuki can directly choose S′={0,1,2,2}S' = \{0,1,2,2\} in the 1st transformation, making S={3}S = \{3\}.
  • It can be proven that no sequence of operations with fewer transformations exists, so the answer is 11.