| Task: | Dynamic Range Minimum Queries |
| Sender: | francden |
| Submission time: | 2025-09-21 20:25:45 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.07 s | details |
| #2 | RUNTIME ERROR | 0.23 s | details |
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-1][a])
return min(min_list[i-1][a],min_list[i-1][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
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: RUNTIME ERROR
| 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 7 4 6 2 ... |
Error:
Traceback (most recent call last):
File "input/code.py", line 57, in <module>
update...Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 200000 398739055 65343131 699208332 3... |
| correct output |
|---|
| 28609 129890 20378 20378 311522 ... |
| user output |
|---|
| 13677 129890 40862 20378 59886 ... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 59, in <module>
print(...