Submission details
Task:Xor sum
Sender:aalto26dm_024
Submission time:2026-09-21 16:26:34 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#20.13 sdetails

Code

import math

def main():
    n, q = [int(x) for x in input().split()]
    values = [int(x) for x in input().split()]

    N = 1
    while N < n:
        N *= 2

    tree = [float('inf')] * N * 2

    for i in range(n):
        tree[N + i] = values[i]
    for i in range(N - 1, 0, -1):
        tree[i] = min(tree[i * 2], tree[i * 2 + 1])

    def update(k, x):
        k += N
        tree[k] = x
        k //= 2
        while k >= 1:
            tree[k] = min(tree[k * 2], tree[k * 2 + 1])
            k //= 2

    def query(a, b):
        a += N
        b += N
        s = float('inf')

        while a <= b:
            if a % 2 == 1:
                s = min(s, tree[a])
                a += 1
            if b % 2 == 0:
                s = min(s, tree[b])
                b -= 1
            a //= 2
            b //= 2
        return s

    for _ in range(q):
        action = [int(x) for x in input().split()]

        if action[0] == 1:
            update(action[1] - 1, action[2])
        else:
            print(query(action[1] - 1, action[2] - 1))

main()

Test details

Test 1

Verdict:

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

correct output
7
1
5
3
1
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 50, in <module>
    main()
  File "/box/input/code.py", line 46, in main
    update(action[1] - 1, action[2])
IndexError: list index out of range

Test 2

Verdict:

input
200000 200000
921726510 307633388 992247073 ...

correct output
834756431
130379787
403037296
308618218
784778243
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 50, in <module>
    main()
  File "/box/input/code.py", line 48, in main
    print(query(action[1] - 1, action[2] - 1))
IndexError: list index out of range