QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 128 MB Puntuación total: 100

#7463. y-fast trie

Estadísticas

Given a constant $C$, you need to maintain a set $S$ and support $n$ operations:

  • Operation 1: Given $x$, insert an element $x$. It is guaranteed that $x$ is not already in the set.
  • Operation 2: Given $x$, delete an element $x$. It is guaranteed that $x$ is currently in the set.

After each operation, you need to output $\max\limits_{\substack{ i, j \in S \\ i \ne j }} \bigl( (i+j) \bmod C \bigr)$, which is the maximum value of the sum of two distinct elements in $S$ modulo $C$. If there are fewer than two elements in $S$, output EE.

This problem is forced online. Each $x$ must be XORed with the answer of the previous operation. If there was no previous query or the previous output was EE, the previous answer is $0$.

Input

The first line contains two integers $n$ and $C$.

The next $n$ lines each contain two integers $1~x$ or $2~x$, representing the first or second type of operation.

Output

Output $n$ lines, where the $i$-th line represents the answer after the $i$-th operation.

Examples

Input 1

7 9
1 2
1 3
1 0
1 14
2 14
2 13
1 1

Output 1

EE
5
8
8
8
5
7

Subtasks

Idea: zhouwc, Solution: ccz181078&nzhtl1477, Code: ccz181078&nzhtl1477, Data: nzhtl1477

Note: This problem uses bundled testing. You only receive points for a subtask if you pass all test cases within that subtask.

For $1\%$ of the data, it is Example 1.

For another $9\%$ of the data, the number of elements in the set is $\le 1$.

For another $19\%$ of the data, $n\leq 500$.

For another $19\%$ of the data, $n\leq 10^4$.

For another $19\%$ of the data, $1\leq n,C \leq 10^5$.

For $100\%$ of the data, $1\leq n \leq 5\times 10^5$, $1\leq C\leq 1073741823$, $0\leq x\leq 1073741823$.

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.