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

建议使用的浏览器:

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

5649:DZY Loves Sorting

题目描述
DZY has a sequence $a[1..n]$. It is a permutation of integers $1 \sim n$.

Now he wants to perform two types of operations:

$0 \,\,l \,\,r$: Sort $a[l..r]$ in increasing order.

$1\,\, l \,\,r$: Sort $a[l..r]$ in decreasing order.

After doing all the operations, he will tell you a position $k$, and ask you the value of $a[k]$.
输入解释
First line contains $t$, denoting the number of testcases.

$t$ testcases follow. For each testcase:

First line contains $n,m$. $m$ is the number of operations.

Second line contains $n$ space-separated integers $a[1],a[2],\cdots,a[n]$, the initial sequence. We ensure that it is a permutation of $1\sim n$.

Then $m$ lines follow. In each line there are three integers $opt,l,r$ to indicate an operation.

Last line contains $k$.

($1\le t \le 50,1\le n,m \le 100000,1\le k \le n, 1\le l\le r\le n, opt \in \{0,1\}$. Sum of $n$ in all testcases does not exceed $150000$. Sum of $m$ in all testcases does not exceed $150000$)
输出解释
For each testcase, output one line - the value of $a[k]$ after performing all $m$ operations.
输入样例
1
6 3
1 6 2 5 3 4
0 1 4
1 3 6
0 2 4
3
输出样例
5

提示
1 6 2 5 3 4 -> [1 2 5 6] 3 4 -> 1 2 [6 5 4 3] -> 1 [2 5 6] 4 3. At last $a[3]=5$.
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5649

最后修改于 2020-10-25T23:24:29+00:00 由爬虫自动更新

共提交 0

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