#P14947. Minpopcount
Minpopcount
Problem Description
Rikka has a set containing elements in , which is initially empty. Then events will happen, each of which is one of the following two types:
- Given an integer , insert into . It is guaranteed that is not in before this operation.
- Given an integer . For all , compute the minimum value of . It is guaranteed that is non-empty before this operation.
Please help Rikka solve this problem by outputting the correct answer for every type event.
Input Format
The first line contains two integers and (, ), representing the number of events and the size of the value range.
The next lines each contain two integers and (, ), describing an event, where is the event type and is the event parameter.
Output Format
For each type event, output one line with one integer representing the answer.
5 3
1 2
1 3
2 5
1 4
2 6
2
1
12 4
1 5
1 11
2 7
2 12
1 3
2 2
1 6
1 0
2 5
2 11
1 14
2 1
1
2
1
0
0
1
40 5
1 7
2 0
2 18
2 23
2 13
2 5
2 30
1 1
2 9
2 5
2 29
2 10
2 29
2 18
2 29
1 20
2 19
2 4
1 18
2 13
2 14
2 10
2 1
1 15
2 28
2 2
1 0
2 19
1 8
2 8
1 13
2 7
1 31
2 1
1 14
2 6
1 30
2 9
2 20
2 4
3
3
1
2
1
3
1
1
3
3
3
3
3
2
1
2
2
2
0
1
1
1
0
0
0
1
1
0
1
Hint
For the first sample, when the first query happens, and . We have and , so the answer to the query is . The second query happens when and . We have , , and , so the answer to the query is .
Translated by ChatGPT 5