原题:
Sequence
1000ms 31072K
描述:
Given an array aa consisting of nn integers, on which you are to perform mm operations of two types.
-
Given two integers x,yx,y, replace the number of index xx with number yy. That is ax:=yax:=y.
-
Given one integer xx, print the number of consecutive subsequences of aa, whose minimum value equals to axax.
It's guaranteed that there are no duplicated value in array aa at any moment.
输入:
The first line contains two intergers n,m(1≤n,m≤105)n,m(1≤n,m≤105), where nn is the size of the array and mm is the number of operations to perform.
The second line contains nn integer, the ithith integer is ai(1≤ai≤231−1)ai(1≤ai≤231−1).
Then, mm lines follow, describing mm operation you are to perform in order.
Each line start with an integer opt∈[1,2]opt∈[1,2], meaning the type of operation to perform.
If opt=1opt=1, two integers x,y(1≤x≤n,1≤y≤231−1)x,y(1≤x≤n,1≤y≤231−1) follows, mentioned above.
If opt=2opt=2, one integer x(1≤x≤n)x(1≤x≤n) follows, mentioned above.
输出:
For each operation of type 22, print one integer on one line as the answer.
(链接:https://acs.jxnu.edu.cn/problem/ICPCJX2020H)
翻译:
序列
有一个数组a,由n个整数组成,对其你可进行m次以下两种类型的操作:
1.给出两个整数x,y,用y替代a中下标为x的数,即a[x]=y;
2.给出一个整数x,表示需要输出的a的连续子串的长度,并它的最小值等于a[x].
任何时候数组a都没有重复的值。
输入:
第一行包括两个整数n,m(1<=n,m<=105),n是数组长度,m是操作次数。
第二行包括n个整数,第i个整数为a[i](1<=ai<=2^(31-1)).
接下来的m行描述你将按顺序进行的操作。
每行开头的一个整数为opt,取值为1或2,代表进行的操作类型。
如果opt=1,输入两个整数x,y(1<=x<=n,1<=y<=2^(31-1)),再按上述操作;
如果opt=2,输出一个整数x(1<=x<=n),再按上述操作。
输出:
对于每次的两种操作,一行输出一个整数代表答案。