AdvancedRating 1800
Update and Minimum
Process q commands: 'U i x' sets position i to x; 'M l r' prints the minimum of positions l … r. Use a segment tree.
Input
n and q; n integers; q commands.
Output
One line per M.
Sample 1
Input
5 4 5 3 8 6 1 M 1 3 U 2 9 M 1 3 M 4 5
Output
3 5 1
Sample 2
Input
43 13 32 39 -50 -37 40 -6 49 -47 6 -25 41 -47 42 -37 5 -44 -40 -6 -41 3 -25 -17 -32 0 12 11 -33 -30 48 -23 -14 -28 -37 -10 17 -16 -43 -45 -41 -37 -25 -32 30 M 4 8 U 16 -50 M 16 37 U 16 -49 U 37 28 U 4 42 M 15 35 U 36 34 M 14 17 M 37 43 M 7 25 M 20 31 M 1 43
Output
-47 -50 -49 -49 -45 -49 -33 -50
Output appears here