#P7898. [Ynoi2006] wcirq
[Ynoi2006] wcirq
Problem Description
This is an interactive problem.
You need to perform primitive operations to maintain a sequence. The initial sequence is empty.
The -th primitive operation gives integers , meaning: insert element before the -th position of the sequence (if , it means inserting at the end of the sequence), and then query the set formed by the -th elements of the sequence.
To answer these queries, you may operate on several sets. These sets are initially empty, indexed by integers from to .
You may spend unit of the first type of cost to perform an insertion operation: insert element into the set with index . Before answering the query of the -th primitive operation, you must ensure .
You may spend units of the second type of cost to answer a query: choose the sets with indices , requiring that these sets are pairwise disjoint, and their union is the answer to the query.
After each primitive operation, the first-type/second-type costs of insertion operations and answering the query must not exceed the current subtask cost limits . The cost of each primitive operation is calculated separately.
Input Format
You need to implement the function:
void solve(int x,int l,int r);
For each primitive operation, this function is called once, and the parameters x l r correspond to .
Output Format
You may call the functions:
void op1(int x,int y);
void op2(int k);
Calling op1 means performing one insertion operation.
Calling op2 in order for means answering the query.
In the submitted code, you need to declare these two functions.
假设交互库调用了3次 `solve` 函数如下:
```cpp
solve(1,1,1);
solve(1,2,2);
solve(2,1,3);
```output1
以下给出了一种符合要求的对 `op1` 和 `op2` 的调用:
```cpp
op1(1,1);
op2(1);
此时序列为 ,编号1的集合为 ,第1次 solve 函数调用返回;
op2(1);
此时序列为 ,编号1的集合为 ,第2次 solve 函数调用返回;
op1(1,2);
op1(2,3);
op2(2);
op2(1);
此时序列为 ,编号1的集合为 ,编号2的集合为 ,第3次 solve 函数调用返回。
## Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078&nzhtl1477.
For $100\%$ of the testdata, it holds that $1\le n\le 10^6$; $1\le x_i\le i$; $1\le l_i\le r_i\le i$.
In the insertion operations or query answers you output, the set indices are in the range $1$ to $2\times 10^7$, and the $y$ in an insertion operation must be an element that already exists in the sequence.
Subtask 1 (10 points): guarantees $1\le n\le 10^3$.
Subtask 2 (10 points): guarantees $l_i=1,\;r_i=i$.
Subtask 3 (10 points): guarantees $x_i=i$.
Subtask 4 (20 points): guarantees $1\le n\le 10^4$.
Subtask 5 (10 points): guarantees $1\le n\le 10^5$.
Subtask 6 (20 points): the data is randomly generated, where $n=10^6$, and $(l_i,r_i)$ and $x_i$ are independently chosen uniformly at random among all possible cases.
Subtask 7 (20 points): no special restrictions.
For Subtask 6, $(m_1,m_2)=(64,64)$.
For all other subtasks, $(m_1,m_2)=(64,256)$.
Translated by ChatGPT 5