~~~ Question Link ~~~
PS: the data on this question is too watery.CodeYes. It should be correct after the change.
# Include <stdio. h> # include <string. h> # define n 2000002 # define max (A, B) A> B? A: bint n = 0, m = 0, ANS = 0, Y [4 * n], num [N]; void Update (int c, int L, int R, int K) {int M = L + (R-l)/2; If (L = r) {// y [c] = max (Y [c], num [k]); y [c] = num [k]; return;} If (M> = k) update (2 * C, L, M, k ); else if (M <k) update (2 * C + 1, m + 1, R, k); y [c] = max (Y [2 * C], Y [2 * C + 1]);} void query (int c, int L, int R, int lf, int RT) {int M = L + (R-l) /2; If (L = lf & R = RT) {ans = max (Y [c], ANS); return;} I F (M> = RT) query (2 * C, L, M, lf, RT); else if (M <LF) query (2 * C + 1, m + 1, R, lf, RT); else {query (2 * C, L, M, lf, m); query (2 * C + 1, m + 1, r, m + 1, RT);} y [c] = max (Y [2 * C], Y [2 * C + 1]);} int main () {int I = 0, a = 0, B = 0; char CH = 0; while (scanf ("% d", & N, & M )! = EOF) {memset (Y,-1, sizeof (y); for (I = 1; I <= N; I ++) scanf ("% d ", num + I); for (I = 1; I <= N; I ++) Update (1, 1, n, I); getchar (); While (M --) {scanf ("% C", & Ch); If (CH = 'q') {ans = 0; scanf ("% d", &, & B); query (1, 1, n, a, B); printf ("% d \ n", ANS );} else {scanf ("% d", & A, & B); num [a] = B; update (1, 1, n, );} getchar () ;}} return 0 ;}