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\}$。你要幫 Yuki 搵出令 $S$ 等於 $\{k\}$ 所需嘅最少變換次數。由於答案可以好大,你只需要輸出答案對 $998244353$ 取模嘅結果。

可以證明,一定存在至少一個操作次序,可以將 $S$ 變成 $\{k\}$。

$*$:一個多重集合嘅 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$),表示測試資料嘅組數。

對每組測試資料:

  • 第一行有兩個整數 $n,k$($1 \le n \le 5 \cdot 10^5$,$0 \le k \le 10^9$)。
  • 第二行有 $n$ 個整數 $s_1,\ldots,s_n$($0 \le s_i \le 10^9$)。

保證所有測試資料嘅 $n$ 總和唔超過 $5 \cdot 10^5$。

輸出格式

對每組測試資料,輸出一行,當中有一個整數,表示令 $S$ 等於 $\{k\}$ 所需嘅最少變換次數對 $998244353$ 取模嘅結果。

樣例

輸入格式 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

說明

對第一組測試資料:

  • Yuki 可以喺第一次變換揀 $S'=\varnothing$,令 $S=\{0,1\}$,再喺第二次變換揀 $S'=\{0,1\}$,令 $S=\{2\}$。
  • 可以證明冇變換次數更少嘅操作次序,所以答案係 $2$。

對第二組測試資料:

  • Yuki 唔使做任何變換就可以令 $S=\{4\}$,所以答案係 $0$。

對第三組測試資料:

  • Yuki 可以喺第一次變換揀 $S'=\varnothing$,令 $S=\{0,0,2,2\}$;喺第二次變換揀 $S'=\{0,2\}$,令 $S=\{0,1,2\}$;再喺第三次變換揀 $S'=\{0,1,2\}$,令 $S=\{3\}$。
  • 可以證明冇變換次數更少嘅操作次序,所以答案係 $3$。

對第四組測試資料:

  • Yuki 可以喺第一次變換揀 $S'=\{2,3\}$,令 $S=\{0,0,1\}$,再喺第二次變換揀 $S'=\{0,0,1\}$,令 $S=\{2\}$。
  • 可以證明冇變換次數更少嘅操作次序,所以答案係 $2$。

對第五組測試資料:

  • Yuki 可以直接喺第一次變換揀 $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.