当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7118:Permutation

题目描述
Given $\{a_i\}$, a permutation of $1...n$, you need to perform the following operations:


  • Reverse a subarray indexed by $[L,R](1\le L\le R \le |a|)$, that is, $\forall i\in [L,\frac{L + R}{2}]$, $\texttt{swap(a[i],a[R+L-i])}$.

  • Complement the elements $a_i$ such that $L\le a_i\le R(1\le L\le R \le |a|)$, that is, $\forall L\le a_i\le R$, assign $\texttt{R+L-a[i]}$ to $\texttt{a[i]}$.

  • Increase all the elements that is no less than $v(1\le v\le |a|+1)$ by $1$, and then insert $v$ before the $i(1\le i\le |a|)$th element. It's clear that the array becomes a permutation of $1...|a|+1$ after that.

  • Given $i(1\le i\le |a|)$, print the value of $a_i$.

  • Given $v(1\le v\le |a|)$, print the position of $v$.

输入解释
This problem contains multiple test cases.

The first line contains a single integer $T$($1 \leq T \leq 10$), the number of test cases.

Each test case starts with a line of two integers $n,m(1\le n,m\le 10^5)$, the initial length of the permutation and the number of operations.

Then follows a line of $n$ numbers, representing a permutation of $1...n$.

For the following $m$ lines, each line is of the following format:


  • $\texttt{1 L R}$, asking you to reverse a subarray.

  • $\texttt{2 L R}$, asking you to complement certain elements.

  • $\texttt{3 i v}$, asking you to insert an element.

  • $\texttt{4 i}$, asking you to print the value of the $i$th element.

  • $\texttt{5 v}$, asking you to print the position of $v$.

输出解释
For each print operation, print a single integer in a line denoting the answer.
输入样例
1
5 5
1 2 3 4 5
1 1 3
2 1 5
3 1 2
4 6
5 2
输出样例
1
1

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7118

最后修改于 2021-10-23T19:11:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
14000/7000MS(Java/Others) 262144/262144K(Java/Others)