Submission details
Task:Dynamic Range Minimum Queries
Sender:francden
Submission time:2025-09-21 20:19:56 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.07 sdetails
#20.00 sdetails

Code

n,q = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
min_list = []
min_list.append(L)
j = 1
power = 2

while power <= n :
    i=0
    curr_list = []
    while i + power - 1 < n:
        curr_list.append(min(min_list[-1][i],min_list[-1][i+power-j]))
        i+=1
    j=power
    power *=2
    if curr_list :
        min_list.append(curr_list)


def mini(a,b):
    if a == b :
        return L[a]
    k = b-a+1
    power = 1
    i = 0
    while k > power :
        power *=2
        i+=1
    if k == power:
        return(min_list[i][a])
    return min(min_list[i][a],min_list[i][b-power])

def update_list(index,value):
    if L[index] < value:
        prev = L[index]
        L[index]=value 
        power = 2
        for i in range(1,len(min_list)):
            #update the min_list
            flag = False
            for k in range(power):
                if index-k >= 0 and index-k <= n-power:
                    if min_list[i][index-k]>value or min_list[i][index-k] == prev:
                        min_list[i][index-k] = min(value,min_list[i-1][index],min_list[i-1][index+power//2-1])
                        flag = True
            if flag == False:
                break
            power*=2

    else :
        L[index] = value
        min_list[0][index]= value
    print(min_list)

for i in range (q):
    a,b,c = [int(x) for x in input().split()]
    if a == 1:
        update_list(b-1,c)
    else :
        print(mini(b-1,c-1))

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
7
6
2
4

Error:
Traceback (most recent call last):
  File "input/code.py", line 60, in <module>
    print(...

Test 2

Verdict:

input
200000 200000
398739055 65343131 699208332 3...

correct output
28609
129890
20378
20378
311522
...

user output
(empty)