| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1.5 초 | 2048 MB | 5 | 5 | 4 | 100.000% |
A subarray of an array $B$ is a contiguous sequence of elements taken from $B$. For example, if $B = [3, 1, 4, 1, 5],ドル then $[3, 1, 4],ドル $[4, 1],ドル the empty array $[ ]$ and the whole array $B$ are subarrays of $B$ (among others), while $[3, 4, 5]$ and $[1, 3]$ are not subarrays of $B$.
We also define $C^m$ as the array obtained by the concatenation of $m$ copies of the array $C$. For example, if $C = [3, 2]$ then $C^1 = [3, 2],ドル $C^2 = [3, 2, 3, 2]$ and $C^∞ = [ \dots , 3, 2, 3, 2, 3, 2, \dots]$.
In this problem you are given an array $P$ containing no repeated numbers, and you have to process a sequence of events that occur in order. The events can be of three types:
Are you ready for this challenge?
The first line contains an integer $N$ (1ドル ≤ N ≤ 5 \cdot 10^5 $) indicating the initial length of $P$.
The second line contains $N$ different integers $P_1, P_2, \dots , P_N$ (1ドル ≤ P_i ≤ 10^6$ for $i = 1, 2, \dots , N$).
The third line contains an integer $E$ (1ドル ≤ E ≤ 5 \cdot 10^5$) representing the number of events that need to be processed.
Each of the next $E$ lines describes an event, in the order they must be processed. The content of the line depends on the event, as follows:
-” (minus sign) and an integer $X$ (1ドル ≤ X ≤ 10^6,ドル and $X \in P$), denoting that $X$ must be deleted from $P$. It is guaranteed that after the removal $P$ does not become empty.+” (plus sign) and two integers $Y$ and $Z$ (1ドル ≤ Y, Z ≤ 10^6,ドル $Y \not\in P,ドル and $Z \in P$), denoting that $Y$ must be inserted into $P$ immediately to the left of $Z$.?” (question mark), a positive integer $K,ドル and $K$ integers $A_1, A_2, \dots , A_K$ (1ドル ≤ A_i ≤ 10^6$ for $i = 1, 2, \dots , K$), indicating that the length of the longest common subarray between $P^∞$ and $A^∞$ must be computed. It is guaranteed that the input contains at least one query, and the sum of $K$ across all the queries is at most 10ドル^6$.Output a line for each query, with an integer indicating the length of the longest common subarray between $P^∞$ and $A^∞,ドル or the character “*” (asterisk) if the length of the longest common subarray is larger than 10ドル^{18}$.
4 1 2 3 4 10 ? 2 3 2 ? 3 99 99 99 - 1 - 4 ? 2 3 3 ? 3 4 1 4 + 64 3 + 1 2 ? 4 1 2 64 3 ? 4 1 3 64 2
2 0 1 0 * 1
1 217 1 ? 1 314
0