Submission details
Task:Xor sum
Sender:aalto26dm_030
Submission time:2026-09-21 17:00:11 +0300
Language:C++ (C++23)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:37:24: error: 'INT_MAX' was not declared in this scope
   37 |             int best = INT_MAX;
      |                        ^~~~~~~
input/code.cpp:6:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 |

Code

#include <iostream>
#include <vector>
#include <string>
#include <format>
#include <algorithm>


int main (int argc, char **argv) {

    int n, q;
    std::cin >> n >> q;

    std::vector<int> numbers(n, 0);
    for (int i=0; i<n; i++) {
        std::cin >> numbers[i];
    }

    //std::cout << std::format("{}", numbers) << std::endl;

    std::vector<int> tree(2 * n);
    for (int i=0; i<n; i++) tree[n + i] = numbers[i];
    for (int i=n-1; i>0; i--) tree[i] = std::min(tree[2*i], tree[2*i+1]);

    std::string result;
    for (int i=0; i<q; i++) {
        int t, a, b;
        std::cin >> t >> a >> b;
        
        if (t == 1) {
            int pos = (a - 1) + n;
            tree[pos] = b;
            for (pos /= 2; pos > 0; pos /= 2)
                tree[pos] = std::min(tree[2*pos], tree[2*pos+1]);
        } else {
            int l = (a - 1) + n;
            int r = b + n;
            int best = INT_MAX;
            while (l < r) {
                if (l & 1) best = std::min(best, tree[l++]);
                if (r & 1) best = std::min(best, tree[--r]);
                l /= 2;
                r /= 2;
            }
            result += std::to_string(best);
            result += '\n';
        }
    }

    std::cout << result << std::endl;


    return 0;
}