QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#17768. 盲盒抽獎

Estadísticas

題目背景

通過了門票考驗並從展覽區入場後,大家便來到了熱鬧的互動大廳。在這裡,小 T 和小 S 特意設置了盲盒抽獎環節。

抽獎攤位上的盲盒會隨著大家的到來而陸續上架。小 T 為此制定了一套別出心裁的兌獎規則:每個人都可以從台上挑出一部分盲盒,並按這些盲盒原有的先後順序兩兩配對。只有當這組盲盒背後的隱藏數字滿足特定的運算條件時,配對才算成功並能兌換相應的獎品。

活動現場總計會陸續上架 $n$ 個盲盒,它們背後的隱藏數字分別為 $a_1, a_2, \dots, a_n$。

在抽獎環節中,若當前台上已經展示了前 $k$ 個盲盒,則參與者可以從中挑選出偶數個盲盒(設其對應原序列的下標為 $1 \le i_1 < i_2 < \dots < i_{2t} \le k$),並將它們按順序依次配對為 $t$ 組,即 $(a_{i_1}, a_{i_2}), (a_{i_3}, a_{i_4}), \dots, (a_{i_{2t-1}}, a_{i_{2t}})$。對於任意一對被挑選出的盲盒,設其背後的隱藏數字分別為 $x$ 和 $y$,則兌獎的條件是:$x$ 與 $y$ 的二進制按位異或結果必須嚴格小於小 T 提前設定的幸運閾值 $m$。滿足該條件的每一對盲盒均可算作有效配對,並兌換一個獎品。

作為熱情的參與者,你也體驗了這場抽獎,但十分遺憾,你選出的盲盒無一滿足兌獎條件。為了安慰運氣不佳的你,小 S 向你拋出了一個挑戰:如果你能正確回答她提出的問題,她便會直接送你一份特別的十週年大獎。

小 S 的問題是:對於每一個 $k \in [1, n]$,當台上恰好展示了前 $k$ 個盲盒時,能夠兌換的最大獎項總數,是否嚴格大於僅展示前 $k - 1$ 個盲盒時的最大數量?

輸入格式

輸入的第一行包含兩個正整數 $n, m$ ($1 \le n \le 5 \times 10^6, 2 \le m \le 10^8$),分別表示盲盒的總數與小 T 提前設定的幸運閾值。

輸入的第二行包含 $n$ 個正整數 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^8$),分別表示每個盲盒背後的隱藏數字。

輸出格式

輸出一行一個長度為 $n$ 的字串。對於每一個 $k \in [1, n]$,若展示前 $k$ 個盲盒能兌換的最大獎項數嚴格大於僅展示前 $k - 1$ 個盲盒時的最大獎項數,則字串的第 $k$ 位為 Y,否則為 N

範例

輸入 1

5 4
1 2 5 4 3

輸出 1

NYNYN

提示

本題輸入量較大,建議使用較為快速的輸入方式。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download
#1606EditorialOpenNew Editorial for Problem #17768Anonymous2026-04-23 00:53:58View

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.