Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #pragma GCC target("avx2")
- #pragma GCC optimize("O3", "unroll-loops")
- // #include <bits/extc++.h>
- // using namespace __gnu_pbds;
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- // template <typename T>
- // using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
- #define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
- #define RANDOM() random_device __rd; \
- mt19937 __gen = mt19937(__rd()); \
- uniform_int_distribution<int> __dis(0, INT_MAX); \
- auto rnd = bind(__dis, __gen);
- const int mod = 1E9 + 7;
- const int maxn = 1 << 18;
- int zkw[2 * maxn];
- int Query(int qL, int qR, int ans = 0) {
- ans = min(zkw[qL += maxn], zkw[qR += maxn]);
- while ((qL >> 1) ^ (qR >> 1)) {
- if (~qL & 1) ans = min(ans, zkw[qL^1]);
- if ( qR & 1) ans = min(ans, zkw[qR^1]);
- qL >>= 1, qR >>= 1;
- }
- return ans;
- }
- void Modify(int x, int val) {
- zkw[x += maxn] = val;
- while (x >>= 1) zkw[x] = min(zkw[x<<1], zkw[x<<1|1]);
- }
- void Build(int n) {
- for (int i = 0; i < n; ++i) cin >> zkw[maxn + i];
- for (int i = maxn-1; i >= 1; --i) zkw[i] = min(zkw[i<<1], zkw[i<<1|1]);
- }
- int32_t main() {
- fastIO();
- int n, q, x, y;
- char c;
- cin >> n >> q;
- Build(n);
- while (q--) {
- cin >> c >> x >> y;
- if (c == 'M') Modify(x, y);
- else cout << Query(x, y) << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement