QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#17741. 畢業前要做的 101 件事

الإحصائيات

Busy Beaver 的大四期末考週到了,他才想起大一新生訓練時收到的一份畢業前必做活動清單。

給你一個包含 $N$ 個數字的陣列 $a_1, \ldots, a_N$,其中 $a_i$ 代表完成第 $i$ 個活動所獲得的快樂值。

由於他在 MIT 的時間有限,他決定只完成這些活動中的一個連續子區段。此外,為了讓效益最大化,該子區段必須包含至少兩個活動。

在準備期末考的拖延過程中,他想出了一種計算子區段分數的複雜方法。從索引 $l$ 到 $r$ 的子區段分數定義為該區段中任兩個不同活動的 XOR 最小值。形式上,從索引 $l$ 到 $r$ 的子區段分數為 $\min\limits_{l \leq i < j \leq r} a_i \oplus a_j$。

Busy Beaver 最喜歡的數字是 $K$,所以他想計算分數為 $K$ 的子區段數量。你能幫幫他嗎?

輸入格式

第一行包含兩個整數 $N$ 和 $K$ ($2 \le N \le 10^5$, $0 \le K < 2^{30}$)。

第二行包含 $N$ 個以空白分隔的整數 $a_1, \dots, a_N$ ($1 \le a_i < 2^{30}$)。

輸出格式

輸出一個整數:分數為 $K$ 且長度至少為二的連續子區段數量。

子任務

  • ($15$ 分) $N \leq 5000$。
  • ($10$ 分) $K = 0$。
  • ($25$ 分) 陣列 $a$ 為非遞減排序 ($a_{1} \leq \ldots \leq a_{N}$)。
  • ($50$ 分) 無額外限制。

範例

輸入 1

5 2
1 3 1 4 5

輸出 1

3

說明

共有三個子區段符合條件:

  • $l = 1, r = 2$。
  • $l = 2, r = 3$。
  • $l = 2, r = 4$。

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.