本场比赛其他题目的题解
A. Domino Disaster
B. MEXor Mixup
C. Carrying Conundrum
D. Expression Evaluation Error
E. Non-Decreasing Dilemma
E. Non-Decreasing Dilemma
题目描述
Alice has recently received an array a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,…,an for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!
However, soon Bob became curious, and as any sane friend would do, asked Alice to perform q q q operations of two types on her array:
- 1 x y 1\ x\ y 1 x y: update the element a x a_x ax to y y y (set a x = y a_x=y ax=y).
- 2 l r 2\ l\ r 2 l r: calculate how many non-decreasing subarrays exist within the subarray [ a l , a l + 1 , … , a r ] [a_l, a_{l+1}, \dots, a_r] [al,al+1,…,ar]. More formally, count the number of pairs of integers ( p , q ) (p,q) (p,q) such that l ≤ p ≤ q ≤ r l\le p\le q\le r l≤p≤q≤r and a p ≤ a p + 1 ≤ d o t s ≤ q q − 1 ≤ a q a_p\le a_{p+1}\le dots\le q_{q-1}\le a_q ap≤a