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

建议使用的浏览器:

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

5193:Go to movies Ⅱ

题目描述
LeLe is tired of playing blocks , so he decides to go to the movies with his friends again.

When the conductor sees LeLe again , he thinks LeLe is a smart boy.If LeLe can accomplish the task given by her ,LeLe and his friends can enjoy a free film!

The task is :
All kids line up($n$ kids in total) and LeLe should find out how many pairs of kids stand in wrong position (the tall kids stands in front of the short kids.$i < j$ && $H_i > H_j$).As time goes by,some friends will join the line and some kids is so impatience that leave the line.LeLe should work out how many pairs of kids stand in wrong position when a kid leaves or joins.

However LeLe knows the relative height of all kids.The shortest is 1,and the tallest is $n$.
输入解释
There are multiple test cases, about $10$ cases.

The first line of input contains two integers $n,m(1 \leq n,m \leq 20000)$.

The second line contains $n$ integers $H_1,H_2,...,H_n(1 \leq H_i \leq n)$,indicate the height of each kids in the initial queue from left to right.

For the next $m$ lines ,each line means a kid leave or join.
$0$ $x$ $y$ means a kid of $y$ height stands behind the $xth$ kid,$x=0$ means stand at the front of the queue.$(1 \leq y \leq n)$
$1$ $x$ indicate the $xth$ (from left to right) kid leave.
输出解释
There are multiple test cases, about $10$ cases.
For each operation puts how many pairs of kids stand in wrong position.
输入样例
5 5
5 4 3 2 1
0 0 2
0 1 3
1 3
1 3
1 3
输出样例
11
13
9
6
4

提示
After operator 1,the height of every kid is 2 5 4 3 2 1. The total pairs of wrong position is 11.
After operator 2,the height of every kid is 2 3 5 4 3 2 1. The total pairs of wrong position is 13.
After operator 3,the height of every kid is 2 3 4 3 2 1. The total pairs of wrong position is 9.
After operator 4,the height of every kid is 2 3 3 2 1. The total pairs of wrong position is 6.
After operator 5,the height of every kid is 2 3 2 1. The total pairs of wrong position is 4.
All operators are legal.
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #34

源链接: HDU-5193

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

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/65536K(Java/Others)