Universal Cup Judging System

Universal Cup

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓
Statistics

Yuki は大きさ $n$ の多重集合 $S=\{s_1,\ldots,s_n\}$ と整数 $k$ を持っています。

Yuki は変換を次のように定義します。

  • $S$ の部分集合 $S'$($S'$ は空集合でもよい)を選び、$S$ から $S'$ を取り除き、$S'$ の $\operatorname{mex}^{*}$ を $S$ に追加します。

Yuki は何回かの変換を行い、$S$ を $\{k\}$ にしたいと考えています。$S$ を $\{k\}$ にするのに必要な変換回数の最小値を求めて、Yuki を助けてください。答えは非常に大きくなることがあるので、$998244353$ で割った余りだけを出力してください。

$S$ を $\{k\}$ に変換する操作列が必ず少なくとも 1 つ存在すると証明できます。

$*$:多重集合の mex は、その多重集合に含まれない最小の非負整数です。例えば、$\operatorname{mex}\{0,1,2\}=3$、$\operatorname{mex}\{1,0,3,1\}=2$、$\operatorname{mex}\varnothing=0$ です。

入力

この問題には複数のテストケースが含まれます。

最初の行には、テストケース数を表す正整数 $t$($1 \le t \le 10^5$)が含まれます。

各テストケースについて:

  • 最初の行には 2 つの整数 $n,k$($1 \le n \le 5 \cdot 10^5$、$0 \le k \le 10^9$)が含まれます。
  • 2 行目には $n$ 個の整数 $s_1,\ldots,s_n$($0 \le s_i \le 10^9$)が含まれます。

すべてのテストケースにわたる $n$ の総和は $5 \cdot 10^5$ 以下であることが保証されます。

出力

各テストケースについて、$S$ を $\{k\}$ にするのに必要な変換回数の最小値を $998244353$ で割った余りを、整数 1 つを含む行に出力してください。

入出力例

入力 1

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

出力 1

2
0
3
2
1
262875292

注記

1 番目のテストケースについて:

  • Yuki は 1 回目の変換で $S'=\varnothing$ を選び $S=\{0,1\}$ とし、続いて 2 回目の変換で $S'=\{0,1\}$ を選び $S=\{2\}$ とすることができます。
  • より少ない変換回数の操作列は存在しないと証明できるので、答えは $2$ です。

2 番目のテストケースについて:

  • Yuki は変換を一度も行わずに $S=\{4\}$ とできるので、答えは $0$ です。

3 番目のテストケースについて:

  • Yuki は 1 回目の変換で $S'=\varnothing$ を選び $S=\{0,0,2,2\}$ とし、2 回目の変換で $S'=\{0,2\}$ を選び $S=\{0,1,2\}$ とし、さらに 3 回目の変換で $S'=\{0,1,2\}$ を選び $S=\{3\}$ とすることができます。
  • より少ない変換回数の操作列は存在しないと証明できるので、答えは $3$ です。

4 番目のテストケースについて:

  • Yuki は 1 回目の変換で $S'=\{2,3\}$ を選び $S=\{0,0,1\}$ とし、続いて 2 回目の変換で $S'=\{0,0,1\}$ を選び $S=\{2\}$ とすることができます。
  • より少ない変換回数の操作列は存在しないと証明できるので、答えは $2$ です。

5 番目のテストケースについて:

  • Yuki は 1 回目の変換で直接 $S'=\{0,1,2,2\}$ を選び、$S=\{3\}$ とすることができます。
  • より少ない変換回数の操作列は存在しないと証明できるので、答えは $1$ です。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.