Universal Cup Judging System

Universal Cup

Süre Sınırı: 1 s Bellek Sınırı: 512 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

長さ $n$ の整数列 $a_1,a_2,\ldots,a_n$ と整数 $x$ が与えられます。

この数列の部分列を次のように定義します。$1,\ldots,n$ から選んだ任意の空でない添字集合 $\{i_1,i_2,\ldots,i_m\}$($i_1<i_2<\cdots<i_m$)について、$a_{i_1},\ldots,a_{i_m}$ を元の順序で取り出したものを部分列と呼びます。その中央値は次のように定義します。選んだ $m$ 個の値を $v_1\le v_2\le\cdots\le v_m$ の順に並べると、

  • $m$ が奇数なら、中央値は中央の値 $v_{(m+1)/2}$ です。
  • $m$ が偶数なら、中央値は中央の 2 つの値の平均 $\frac{v_{m/2}+v_{m/2+1}}{2}$ です(この平均は整数とは限りませんが、この問題では $x$ と厳密に等しいかどうかだけを考えます)。

中央値が厳密に $x$ に等しい部分列の個数を求めてください。この個数は非常に大きくなる可能性があるので、$998\,244\,353$ で割った余りを出力してください。

注意:異なる 2 つの添字集合によって、選ばれた値の多重集合が完全に同じになった場合でも(数列に同じ数が複数含まれる可能性があるため、このようなことが起こります)、それらは異なる 2 つの部分列として数えます。部分列を区別するのは、選ばれた値の多重集合ではなく、添字集合そのものです。空の添字集合は部分列ではなく、数えることはありません。

入力

各テストには複数のテストケースが含まれます。最初の行にはテストケースの個数 $t$($1\le t\le 10^4$)が与えられます。

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

  • 最初の行には 2 つの整数 $n$ と $x$($1\le n\le 2\times 10^5$、$-10^9\le x\le 10^9$)が与えられます。これらは数列 $a$ の長さと目標の中央値を表します。
  • 2 行目には $n$ 個の整数 $a_1,a_2,\ldots,a_n$($-10^9\le a_i\le 10^9$)が与えられ、与えられる数列の要素を表します。

すべてのテストケースにおける $n$ の総和は $2\times 10^5$ を超えないことが保証されます。

出力

各テストケースについて、中央値が厳密に $x$ に等しい部分列の個数を $998\,244\,353$ で割った余りを、1 行に 1 つの整数として出力してください。

入出力例

入力 1

2
5 3
1 3 5 3 2
2 0
-1 1

出力 1

14
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.