Submission details
Task:Dynamic Range Minimum Queries
Sender:aalto26dh_046
Submission time:2026-09-21 00:31:52 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.26 sdetails

Code

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

// debug
template<class T> ostream& operator<<(ostream&, const vector<T>&);
template<class T> ostream& operator<<(ostream&, const set<T>&);
template<class T> ostream& operator<<(ostream&, const multiset<T>&);
template<class K, class V> ostream& operator<<(ostream&, const map<K, V>&);
template<class T, size_t N> ostream& operator<<(ostream&, const array<T, N>&);
template<class A, class B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << "(" << p.first << ", " << p.second << ")"; };
template<class T>
void print_collection(ostream& os, const T& v) {
    os << "{";
    bool first = true;
    for (const auto& x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << "}";
}
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { print_collection(os, v); return os; }
template<class T> ostream& operator<<(ostream& os, const set<T>& v) { print_collection(os, v); return os; }
template<class T> ostream& operator<<(ostream& os, const multiset<T>& v) { print_collection(os, v); return os; }
template<class K, class V> ostream& operator<<(ostream& os, const map<K, V>& v) { print_collection(os, v); return os; }
template<class T, size_t N> ostream& operator<<(ostream& os, const array<T, N>& v) { print_collection(os, v); return os; }
#define dbg(x) cerr << #x << " = " << (x) << '\n'

using ll = long long;
constexpr int INF = 1'000'000'000; // 1e9
constexpr ll LINF = 1'000'000'000'000'000'000LL; // 1e18
constexpr int MOD = 1'000'000'007; // 1e9 + 7

inline ll add(ll a, ll b) { return (a + b) % MOD; }
inline ll sub(ll a, ll b) { return ((a - b) % MOD + MOD) % MOD; }
inline ll mul(ll a, ll b) { return (a * b) % MOD; }

struct SegTree {
    using T = ll;

    static T op(T a, T b) {
        return min(a,b);
    }

    static T neutral() {
        return LINF;
    }

    int n;
    vector<T> tree;

    SegTree(const vector<int>& x) {
        n = x.size();
        tree.resize(2 * n, neutral());

        for (int i = 0; i < n; ++i)
            tree[n + i] = x[i];

        for (int i = n - 1; i > 0; --i)
            tree[i] = op(tree[i << 1], tree[i << 1 | 1]);
    }

    void set(int k, T x) {
        k += n;
        tree[k] = x;

        while (k > 1) {
            k >>= 1;
            tree[k] = op(tree[k << 1], tree[k << 1 | 1]);
        }
    }

    T query(int a, int b) {
        T left = neutral();
        T right = neutral();

        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1)
                left = op(left, tree[a++]);

            if (b & 1)
                right = op(tree[--b], right);
        }

        return op(left, right);
    }
};

void solve() {
    int n, q;
    cin >> n >> q;

    vector<int> x(n);
    for(int i=0;i<n;++i) {
        cin >> x[i];
    }

    SegTree tree = SegTree(x);

    int t, a, b;
    for(int i=0; i<q;i++) {
        cin >> t >> a >> b;

        if(t==1) {
            tree.set(a-1, b);
        } else {
            cout << tree.query(a-1, b-1) << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    return 0;
}

Test details

Test 1

Verdict:

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
1000000000000000000
7
6
4
4
...

Feedback: Incorrect character on line 1 col 1: expected "7", got "100000000000..."

Test 2

Verdict:

input
200000 200000
398739055 65343131 699208332 3...

correct output
28609
129890
20378
20378
311522
...

user output
28609
129890
20378
20378
311522
...

Feedback: Incorrect character on line 4655 col 1: expected "5642506", got "7651034"