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.