Submission details
Task:Dynamic Range Minimum Queries
Sender:aalto26dh_014
Submission time:2026-09-21 15:46:40 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.12 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:35:21: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   35 |             int m = 10000000000;
      |                     ^~~~~~~~~~~

Code

#include <bits/stdc++.h> 
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> tree(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> tree[n + i];
    }
    for (int i = n - 1; i > 0; --i) {
        tree[i] = min(tree[2 * i], tree[2 * i + 1]);
    }
    
    for (int i = 0; i < q; i++) {
        int quer;
        cin >> quer;
        if (quer == 1) {
            int k, u;
            cin >> k >> u;
            k--; 
            k += n; 
            tree[k] = u;
            for (k /= 2; k >= 1; k /= 2) {
                tree[k] = min(tree[2 * k], tree[2 * k + 1]);
            }
        } 
        else {
            int a, b;
            cin >> a >> b;
            a--; b--; 
            a += n; b += n;
            int m = 10000000000; 
            while (a <= b) {
                if (a % 2 == 1) m = min(m, tree[a++]);
                if (b % 2 == 0) m = min(m, tree[b--]);
                a /= 2; b /= 2;
            }
            cout << m << "\n";
        }
    }
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
8 80
7 6 4 6 2 9 4 8
2 1 1
2 1 2
2 1 3
...

correct output
7
6
4
4
2
...

user output
7
6
4
4
2
...

Test 2

Verdict: ACCEPTED

input
200000 200000
398739055 65343131 699208332 3...

correct output
28609
129890
20378
20378
311522
...

user output
28609
129890
20378
20378
311522
...