Description |
|
|
Old manager is a smart and competent person. He has been working for the financial owner for 10 years, and the financial owner wants to make his account clearer. The manager is required to keep K accounts every day. Because the manager is smart and competent, the manager always makes the manager very satisfied. However, some people have doubts about the manager because of their provocation. So he decided to use a special method to judge the loyalty of the butler. He pressed every account to 1, 2, 3... Number, and then occasionally ask the manager's question, the question is: what is the smallest sum of Accounts A to B? In order to prevent the butler from committing frauds, he always asks multiple questions at a time. The account book content may be modified during the inquiry. |
|
|
|
|
|
|
|
Input Format |
|
|
In the input, the first row has two numbers of M, N indicates M (M <= 100000), N indicates n problems, and n <= 100000. Next, there are three numbers for each behavior. The first p is the number 1 or number 2, the second is X, and the third is Y. If p = 1, query the X and Y intervals. If P = 2, the number of X is changed to y. |
|
|
|
|
|
|
|
Output Format |
|
|
The output file contains the answer to each question. For details, see the example. |
|
|
|
|
|
|
|
Sample Input |
|
|
10 3 <br/> 1 2 3 4 5 6 7 8 9 10 <br/> 1 2 7 <br/> 2 2 2 0 <br/> 1 1 10 |
|
|
|
|
|
|
|
Sample output sample output |
|
|
2 0 |
|
|
|
|
|
|
|
Time Limit |
|
|
1 s for each test point |
Added a change to the previous loyal customer base.
Accode:
# Include <cstdio> # include <cstring> # include <cstdlib> # include <bitset> Using STD: min; const char fi [] = "tyvj1039.in "; const char fo [] = "tyvj1039.out"; const int maxn = 100010; const int maxm = 100010; const int max = 0x3fffff00; const int min =-Max; struct segtree {int L, R, LC, RC, Min ;}; segtree [maxm <1]; int T [maxn]; int n, m, TOT; void init_file () {freopen (FI, "r", stdin); freopen (FO, "W", St Dout);} void build (int l, int R) {int now = ++ tot; tree [now]. L = L; tree [now]. R = r; If (L = r) {tree [now]. min = T [l]; return;} int mid = (L + r)> 1; if (L <r) {tree [now]. lc = tot + 1; build (L, mid); tree [now]. rc = tot + 1; build (Mid + 1, R);} tree [now]. min = min (tree [tree [now]. LC]. min, tree [tree [now]. RC]. min);} void modify (INT now, int p) {If (tree [now]. L = tree [now]. R & tree [now]. l = P) {tree [now]. min = T [p]; return;} // locate the object and modify it directly. Int mid = (tree [now]. L + tree [now]. r)> 1; if (P <= mid) Modify (tree [now]. LC, P); // In the left subregion, find the left subregion. If (P> mid) Modify (tree [now]. RC, P); // find the right sub-region in the right sub-region. Tree [now]. min = min (tree [tree [now]. LC]. min, tree [tree [now]. RC]. min);} int query (INT now, int L, int R) {If (L <= tree [now]. L & R> = tree [now]. r) return tree [now]. min; int mid = (tree [now]. L + tree [now]. r)> 1; if (r <= mid) return query (tree [now]. LC, L, R); If (mid <L) return query (tree [now]. RC, L, R); int lc = query (tree [now]. LC, L, R), Rc = query (tree [now]. RC, L, R); Return min (LC, RC);} void work () {scanf ("% d", & N, & M ); for (INT I = 1; I <n + 1; ++ I) scanf ("% d", T + I); Tot = 0; build (1, N ); for (; m; -- m) {int o, X, Y; scanf ("% d", & O, & X, & Y ); switch (o) {Case 1: printf ("% d \ n", query (1, x, y); break; Case 2: T [x] = y; modify (1, x); break ;}} int main () {init_file (); Work (); exit (0 );}