Problem:

Range Minimum Query (RMQ)

Write a program which manipulates a sequence A = {a0, a1, . . .  , an-1} with the following operations:

find(s, t): report the minimum element in as, as+1, . . . ,at.

update(i, x): change ai to x.

Note that the initial values of ai (i = 0, 1, . . .  , n&minus;1) are  231-1.

Input

n q
com0 x0 y0
com1 x1 y1
...
comq&minus;1 xq&minus;1 yq&minus;1

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).

Output

For each find operation, print the minimum element.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

If comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.

If comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.

Sample Input 1

3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

Sample Output 1

1
2

Sample Input 2

1 3
1 0 0
0 0 5
1 0 0

Sample Output 2

2147483647
5



Sample input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2


Sample output:
1
2

Submission status: Wrong Answer

Solution code:
import sys
import time
import math
sys.setrecursionlimit(20000)
def update(tree,x,y,N):
    # offset
    #x += (N - 1)/2
    x += N - 1
    tree[x] = y
    # segment tree no update suru
    while x>0:
        x = math.floor((x - 1)/2)
        left = x*2+1
        right = x*2+2
        tree[x] = min(tree[left],tree[right])

def find(tree,x,y,k,l,r):

    if (r <= x or y <= l):
        return 2**31 - 1
    # sita wo mite itte mitukatta toki (intersect)
    if ( x <= l and r <= y):
        return tree[k]

    # sita ni sagaru
    v_left = find(tree, x, y, k*2 + 1, l, int((l+r)/2))
    v_right = find(tree, x, y, k*2 + 2, int((l+r)/2), r)
    return min(v_left, v_right)

if __name__ == '__main__':
    _N,query_num = map(int, input().split())
    INT_MAX = 2**31 - 1
    N = 1
    while True:
        N *= 2
        if(N >= _N):
            break
    N = 2*N - 1
    A_bin_tree = [INT_MAX]*(N)
    #print(A_bin_tree)
    start = time.time()
    for i in range(query_num):
        operate,x,y = map(int, input().split())
        # update
        if(operate==0):
            update(A_bin_tree,x,y,_N)
            #print(A_bin_tree)
        # find
        if(operate==1):
            # tyouten kara miteiku
            z = find(A_bin_tree,x,y+1,0,0,N-1)
            print(z)
    elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

Submission status: Wrong Answer

Solution code:

A = []

def update(i, x):
    A[i] = x

def find(s, t):
    return min(A[s:t+1])

if __name__ == "__main__":
    n, q = map(int, input().split())
    A = [0] * n 
    for i in range(q):
        com, x, y = map(int, input().split())
        if com == 0:
            update(x, y)
        else:
            m = find(x, y)
            print(m)

Submission status: Wrong Answer

Solution code:

def update(i, x):
    i += n - 1
    A[i] = x
    while i >= 0:
        i = (i - 1) >> 1
        A[i] = min(A[2*i+1], A[2*i+2])


def find(s, t):
    S = s + n
    T = t + n
    l = 2**31 - 1
    while S < T:
        if T & 1:
            T -= 1
            l = min(l, A[T-1])

        if S & 1:
            l = min(l, A[S-1])
            S += 1
        S >>= 1
        T >>= 1
    return l


n, q = map(int, input().split())
n = 2**(n-1).bit_length()
A = [2**31 - 1] * (2 * n)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        update(x, y)
    else:
        m = find(x, y)
        print(m)

Submission status: Wrong Answer

Solution code:
M = 2147483647
a = [M for i in range(100000)]

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2
    for i in range(1,t*2):
        a[i]=M

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int):
               a[int(x/2)]=min(a[int(x)],a[int(x)^1])
               x/=2

Submission status: Wrong Answer

Solution code:
class SegmentTree():
    def __init__(self, n):
        self.n = 2**(n-1).bit_length()
        self.data = [float('inf')]*(2*self.n)

    def update(self, k, a):
        k += self.n-1
        self.data[k] = a

        while k >= 0:
            k = (k-1)//2
            self.data[k] = min(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        L = l+self.n
        R = r+self.n
        ret = float('inf')
        while L < R:
            if R & 1:
                R -= 1
                ret = min(ret, self.data[R-1])
            if L & 1:
                ret = min(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


n, q = map(int, input().split())
T = SegmentTree(n)

ans = []
for _ in range(q):
    c, x, y = map(int, input().split())
    if c:
        ans.append(T.query(x, y))
    else:
        T.update(x, y)
print("\n".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
M = 2147483647
a = [M for i in range(100000)]

def j_min(x,y):
    if x < y:return x
    else: return y

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :
            print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int):
               a[int(x/2)]=j_min(a[int(x)],a[int(x)^1])
               x/=2

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n,q = map(int,input().split())
sqrt_n=int(n**0.5)
d=[2**31-1 for i in range(n)]
dd=[2**31-1 for i in range(sqrt_n+1)]
for i in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        d[x]=y
        if x//sqrt_n < sqrt_n+1:
            dd[x//sqrt_n]=min(dd[x//sqrt_n],d[x])
    else:
        tmp=2**31-1
        for j in range(sqrt_n+1):
            l,r=sqrt_n*j,sqrt_n*(j+1)
            if r<=x or y<l:
                continue
            elif x<=l and r <= y+1:
                tmp=min(tmp,dd[j])
            else:
                for k in range(max(x,l),min(y+1,r)):
                    tmp=min(tmp,d[k])
        print(tmp)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n,q = map(int,input().split())
sqrt_n=int(n**0.5)
d=[2**31-1 for i in range(n)]
dd=[2**31-1 for i in range(sqrt_n+1)]
for i in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        d[x]=y
        if x//sqrt_n < sqrt_n+1:
            dd[x//sqrt_n]=min(d[sqrt_n * x//sqrt_n : sqrt_n * (x//sqrt_n + 1)])
    else:
        tmp=2**31-1
        for j in range(sqrt_n+1):
            l,r=sqrt_n*j,sqrt_n*(j+1)
            if r<=x or y<l:
                continue
            elif x<=l and r <= y+1:
                tmp=min(tmp,dd[j])
            else:
                for k in range(max(x,l),min(y+1,r)):
                    tmp=min(tmp,d[k])
        print(tmp)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
class SqrtDecomposition:
    # RMQ用平方分割
    
    # n:要素数 init:配列初期値
    def __init__(self,n,init=0):
        self.data=[init for i in range(n)]
        self.sqrt_n=int(n**0.5)+1
        self.bucket=[init for i in range(self.sqrt_n)]
    
    # x を y にする
    def update(self,x,y):
        self.data[x] = y
        tmp = self.bucket[x//self.sqrt_n]
        for i in range(x//self.sqrt_n * self.sqrt_n, min((x//self.sqrt_n + 1) * self.sqrt_n, n)):
            if tmp > self.data[i]:
                tmp = self.data[i]
        self.bucket[x//self.sqrt_n] = tmp
    
    # [x,y) の最小を求める
    def find(self,x,y):
        tmp = 10**19
        for i in range(self.sqrt_n):
            l,r=i*self.sqrt_n,(i+1)*self.sqrt_n
            if r <= x or y <= l :
                continue
            if x <= l and r <= y :
                tmp = min(tmp, self.bucket[i]);
            else:
                for j in range(max(x, l),min(y, r)):
                    tmp = min(tmp, self.data[i]);
        return tmp


n,q = map(int,input().split())
sd=SqrtDecomposition(n,2**31-1)
for i in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        sd.update(x,y)
    else:
        print(sd.find(x,y+1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
class SqrtDecomposition:
    # RMQ用平方分割
    
    # n:要素数 init:配列初期値
    def __init__(self,n,init=0):
        self.data=[init for i in range(n)]
        self.sqrt_n=int(n**0.5)+1
        self.bucket=[init for i in range(self.sqrt_n)]
    
    # x を y にする
    def update(self,x,y):
        self.data[x] = y
        tmp = self.data[x//self.sqrt_n * self.sqrt_n]
        for i in range(x//self.sqrt_n * self.sqrt_n, min(x//self.sqrt_n * self.sqrt_n + self.sqrt_n, n)):
            if tmp > self.data[i]:
                tmp = self.data[i]
        self.bucket[x//self.sqrt_n] = tmp
        print(self.data)
        print(self.bucket)
    
    # [x,y) の最小を求める
    def find(self,x,y):
        tmp = 10**19
        for i in range(self.sqrt_n):
            l,r=i*self.sqrt_n,(i+1)*self.sqrt_n
            if r <= x or y <= l :
                continue
            if x <= l and r <= y :
                tmp = min(tmp, self.bucket[i]);
            else:
                for j in range(max(x, l),min(y, r)):
                    tmp = min(tmp, self.data[i]);
        return tmp


n,q = map(int,input().split())
sd=SqrtDecomposition(n,2**31-1)
for i in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        sd.update(x,y)
    else:
        print(sd.find(x,y+1))

Submission status: Wrong Answer

Solution code:
import sys
import itertools

class RMQ:
    def __init__(self, n):
        self.sz = 1
        while self.sz < n: self.sz = self.sz << 1
        self.dat = [sys.maxint] * (2 * self.sz - 1)
    
    def update(self, idx, x):
        idx += self.sz - 1
        self.dat[idx] = x
        while idx > 0:
            idx = (idx - 1) >> 1
            self.dat[idx] = min(self.dat[idx * 2 + 1], self.dat[idx * 2 + 2])
            
    def query(self, a, b):
        return self.query_help(a, b, 0, 0, self.sz)
            
    def query_help(self, a, b, k, l, r):
        if r <= a or b <= l:
            return sys.maxint
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            return min(self.query_help(a, b, 2 * k + 1, l, (l + r)>>1),
                        self.query_help(a, b, 2 * k + 2, (l + r) >> 1, r))
    
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    n, q = line.split()
    n, q = int(n), int(q)
    rmq = RMQ(n)
    
    for i in range(q):
        line = sys.stdin.readline()
        op, a, b = line.split()
        op, a, b = int(op), int(a), int(b)
        if op == 0: 
            rmq.update(a, b)
        else: 
            sys.stdout.write(str(rmq.query(a, b + 1)) + '\n')

Submission status: Wrong Answer

Solution code:
class RangeMinimumQuery(object):

    def __init__(self, size):
        self.size = 1
        while self.size < size:
            self.size *= 2
        self.data = [float("inf") for _ in xrange(self.size*2+2)]

    def update(self, idx, value):
        k = idx + self.size - 1
        self.data[k] = value
        while k > 0:
            k = (k - 1) / 2
            self.data[k] = min(self.data[k*2+1], self.data[k*2+2])

    def find(self, start, end):
        def query(k, left, right):
            if right <= start or end <= left:
                return float("inf")
            if start <= left and right <= end:
                return self.data[k]
            vl = query(k*2+1, left, (left+right)/2)
            vr = query(k*2+2, (left+right)/2, right)
            return min(vl, vr)
        return query(0, 0, self.size)


def main():
    n, q = map(int, raw_input().split())
    inf = 1 << 31 - 1
    rmq = RangeMinimumQuery(n)
    for _ in xrange(q):
        com, x, y = map(int, raw_input().split())
        if com == 0:
            rmq.update(x, y)
        else:
            v = rmq.find(x, y+1)
            print v if v != float("inf") else inf

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# Range Minimum Query
# sqrt(100000) = 316.227...

n,q = map(int,raw_input().split())
A = [2**31-1]*n
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[:yi+1])
    elif comi and yi >= 316:
        print min(A[xi:(xi/316 + 1)*316-1]+B[xi/316+1:yi/316]+A[(yi/316)*3:yi+1])
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

Submission status: Wrong Answer

Solution code:
# Range Minimum Query
# sqrt(100000) = 316.227...

n,q = map(int,raw_input().split())
A = [2**31-1]*n
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[:yi+1])
    elif comi and yi >= 316:
        print min(A[xi:(xi/316 + 1)*316-1],B[xi/316+1:yi/316],A[(yi/316)*3:yi+1])
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

Submission status: Wrong Answer

Solution code:
# Range Minimum Query
# sqrt(100000) = 316.227...

n,q = map(int,raw_input().split())
A = [2**31-1]*n
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[:yi+1])
    elif comi and yi >= 316:
        print min(A[xi:(xi/316 + 1)*316-1],B[xi/316+1:yi/316],A[(yi/316)*316:yi+1])
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

Submission status: Wrong Answer

Solution code:
# Range Minimum Query
# sqrt(100000) = 316.227...

n,q = map(int,raw_input().split())
A = [[2**31-1] for i in xrange(n)]
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[xi:yi+1])
    elif comi and yi >= 316:
        print min(A[xi:(xi/316 + 1)*316],B[xi/316+1:yi/316],A[(yi/316)*316:yi+1])
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

Submission status: Wrong Answer

Solution code:
n,q = map(int,raw_input().split())
A = [[2**31-1] for i in range(n)]
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[xi:yi+1])
    elif comi and yi >= 316:
        print min(A[xi:(xi/316 + 1)*316],B[xi/316+1:yi/316],A[(yi/316)*316:yi+1])
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n, q = map(int,raw_input().split())
A = [2**31-1 for i in xrange(100000)]
B = [2**31-1 for i in xrange(101)]

def update(i,x):
    if A[i] == 2**31-1:
        A[i] = x
        B[i/1000] = min(x, B[i/1000])
    else:
        A[i] = x
        MIN = 2**31-1
        for j in xrange(i/1000 * 1000, (i/1000 + 1) * 1000):
            if A[j] < MIN:
                MIN = A[j]
        B[i/1000]

def find(s,t):
    MIN = 2**31-1
    if s/1000 == t/1000 or s/1000 + 1 == t/1000:
        for i in xrange(s, t+1):
            if A[i] < MIN:
                MIN = A[i]
    else:
        #left range
        for i in xrange(s, (s/1000 + 1) * 1000):
            if A[i] < MIN:
                MIN = A[i]
        #middle range
        for j in xrange(s/1000 + 1, t/1000):
            if B[j] < MIN:
                MIN = B[j]
        
        #right range
        for i in xrange(t/1000 * 1000, t+1):
            if A[i] < MIN:
                MIN = A[i]
    print MIN   
    
for i in xrange(q):
    com, s, t = map(int,raw_input().split())
    if com: #find
        find(s,t)
    else: #update
        update(s,t)

Submission status: Wrong Answer

Solution code:
import time

N, Q = map(int, input().split())
SegTree = [0 for i in range(4*N)]

def modify(i, left, right, value, pos=-1):
    global SegTree
    if left==right:
        if pos != -1:
            SegTree[i] = value
        else:
            SegTree[i] = 2147483647
        return

    mid = int((left+right)/2)
    if pos==-1 or pos<=mid:
        modify(i*2, left, mid, value, pos)
    if pos==-1 or pos>mid:
        modify(i*2+1, mid+1, right, value, pos)
    
    SegTree[i] = min(SegTree[i*2], SegTree[i*2+1])

def query_min(i, L, R, left, right):
    if right < L or R < left:
        return 2147364748
    if left<=L and R<=right:
        return SegTree[i]
    mid = int((L+R)/2)
    return min(query_min(2*i, L, mid, left, right),
               query_min(2*i+1, mid+1, R, left, right))

modify(i=1, left=0, right=N-1, value=0, pos=-1) #init

for querys in range(Q):
    t, a, b = map(int, input().split())
    if t == 0:
        modify(i=1, left=0, right=N-1, pos=a, value=b)
    else:
        print( query_min(i=1, L=0, R=N-1, left=a, right=b) )

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def_val = 2 ** 31 - 1
n, q = map(int, input().split())
unit = ceil(sqrt(n))

l = [(def_val, [def_val] * unit) for _ in range(unit)]

while q:
    op, s, t = map(int, input().split())
    sd, sm = s // unit, s % unit
    if op:
        td, tm = t // unit, t % unit
        unit_min = min((tup[0] for tup in l[sd + 1:td]), default=def_val)
        s_min = min(l[sd][1][sm:], default=def_val)
        t_min = min(l[td][1][:tm + 1], default=def_val)
        print(min(unit_min, s_min, t_min))
    else:
        tup = l[sd]
        tup[1][sm] = t
        l[sd] = (min(tup[0], t), tup[1])
    q -= 1

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def_val = 2 ** 31 - 1
n, q = map(int, input().split())
unit = ceil(sqrt(n))

l = [(def_val, [def_val] * unit) for _ in range(unit)]

while q:
    op, s, t = map(int, input().split())
    sd, sm = s // unit, s % unit
    if op:
        td, tm = t // unit, t % unit
        if sd == td:
            print(min(l[sd][1][sm:tm + 1]))
        else:
            unit_min = min((tup[0] for tup in l[sd + 1:td]), default=def_val)
            s_min = min(l[sd][1][sm:], default=def_val)
            t_min = min(l[td][1][:tm + 1], default=def_val)
            print(min(unit_min, s_min, t_min))
    else:
        tup = l[sd]
        tup[1][sm] = t
        l[sd] = (min(tup[0], t), tup[1])
    q -= 1

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
import math

# main
n, q = map(int, input().split())
b_size = math.ceil(math.sqrt(n))
b_len = math.ceil(n/b_size)
a = [2 ** 31 - 1 for i in range(n)]
b = [min(a[b_size * i:b_size * (i + 1)]) for i in range(b_len)]
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        # update
        a[x] = y
        # update b
        index = x // b_size
        if b[index] > y:
            b[index] = y
    else:
        # find
        target = []
        x_index = x // b_size
        y_index = y // b_size
        x_mod = x % b_size
        y_mod = y % b_size
        if x_index == y_index:
            target.extend(a[x:y + 1])
        else:
            if x_mod == 0:
                target.append(b[x_index])
            else:
                target.extend(a[x:x + (4 - 1)])

            if y_mod == 3:
                target.append(b[y_index])
            else:
                target.extend(a[y_index * b_size:y])

            if x_index + 1 <= y_index - 1:
                target.append(min(b[x_index + 1 : y_index - 1]))
        print(min(target))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
import math

# main
n, q = map(int, input().split())
b_size = math.ceil(math.sqrt(n))
b_len = math.ceil(n/b_size)
a = [2 ** 31 - 1 for i in range(n)]
b = [min(a[b_size * i:b_size * (i + 1)]) for i in range(b_len)]
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        # update
        a[x] = y
        # update b
        index = x // b_size
        if b[index] > y:
            b[index] = y
    else:
        # find
        target = []
        x_index = x // b_size
        y_index = y // b_size
        x_mod = x % b_size
        y_mod = y % b_size
        if x_index == y_index:
            target.extend(a[x:y + 1])
        else:
            if x_mod == 0:
                target.append(b[x_index])
            else:
                target.extend(a[x:(x_index + 1) * b_size])

            if y_mod == 3:
                target.append(b[y_index])
            else:
                target.extend(a[y_index * b_size:y + 1])

            if x_index + 1 <= y_index - 1:
                target.append(min(b[x_index + 1 : y_index]))
        print(min(target))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
import math

# main
n, q = map(int, input().split())
b_size = math.ceil(math.sqrt(n))
b_len = math.ceil(n/b_size)
a = [2 ** 31 - 1 for i in range(n)]
b = [min(a[b_size * i:b_size * (i + 1)]) for i in range(b_len)]
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        # update
        a[x] = y
        # update b
        index = x // b_size
        b[index] = min(a[index * b_size:(index + 1) * b_size + 1])

    else:
        # find
        target = []
        x_index = x // b_size
        y_index = y // b_size
        x_mod = x % b_size
        y_mod = y % b_size
        if x_index == y_index:
            target.extend(a[x:y + 1])
        else:
            if x_mod == 0:
                target.append(b[x_index])
            else:
                target.extend(a[x:(x_index + 1) * b_size])

            if y_mod == b_size - 1:
                target.append(b[y_index])
            else:
                target.extend(a[y_index * b_size:y + 1])

            if x_index + 1 <= y_index - 1:
                target.append(min(b[x_index + 1 : y_index]))
        print(min(target))

Submission status: Wrong Answer

Solution code:
#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
output=[]

l = raw_input().split()
#l=input[0].split()

n=l[0]
a=range(0,int(n))
for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
	else:
		output.append(min(a[int(l[1]):int(l[2])+1]))

for i in output:
	print i

Submission status: Wrong Answer

Solution code:
#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
output=[]

l = raw_input().split()
#l=input[0].split()

n=int(l[0])
a = range(0,n)
for i in range(0,n):
	a[0] = 2 ** 31 - 1

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
	else:
		output.append(min(a[int(l[1]):int(l[2])+1]))

for i in output:
	print i

Submission status: Wrong Answer

Solution code:
#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
#input = ["2 15","1 0 1","1 0 0","1 1 1","0 0 2","1 0 1","1 0 0","1 1 1","0 1 1","1 0 1","1 0 0","1 1 1","0 1 5","1 0 1","1 0 0","1 1 1"]
output=[]

l = raw_input().split()
#l=input[0].split()

n = int(l[0])
a = [214783647]*n

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
	else:
		output.append(min(a[int(l[1]):int(l[2])+1]))

for i in output:
	print i

Submission status: Wrong Answer

Solution code:
#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
#input = ["2 15","1 0 1","1 0 0","1 1 1","0 0 2","1 0 1","1 0 0","1 1 1","0 1 1","1 0 1","1 0 0","1 1 1","0 1 5","1 0 1","1 0 0","1 1 1"]
#input = ["1 5","1 0 0","0 0 5","1 0 0","0 0 8","1 0 0"]

l = raw_input().split()
#l=input[0].split()

n = int(l[0])
a = [2147483647]*50000
change = 1

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
		change = 1
	elif change==1:
		m = min(a[int(l[1]):int(l[2])+1])
		change = 0
		print m
	else:
		print m

Submission status: Wrong Answer

Solution code:
l = raw_input().split()
#l=input[0].split()

n = int(l[0])
a = [2147483647]*n

s = 999999
e = 0

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
		s = 999999
	elif s<=int(l[1]) and int(l[2])<=e:
		print m
	else:
		change = l[1]+l[2]
		s = int(l[1])
		e = int(l[2])
		m = min(a[int(l[1]):int(l[2])+1])
		print m

Submission status: Wrong Answer

Solution code:
import math
num,query = (int(n) for n in input().split(' '))
table = [2**31 - 1 for n in range(num)]
sqrttable = []
sqrtnum = math.floor(math.sqrt(num))
tempmin = float("inf")
for t in range(num):
    if t % sqrtnum == sqrtnum - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    elif t == num - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    else:
        tempmin = min(table[t],tempmin)

for q in range(query):
    #print(sqrtnum,table,sqrttable)
    temp = [int(n) for n in input().split(' ')]
    if temp[0] == 0:
        table[temp[1]] = temp[2]
        tempmin = float("inf")
        for tm in range(sqrtnum*(temp[1]//sqrtnum),min(num,sqrtnum*(temp[1]//sqrtnum + 1))):
            tempmin = min(table[tm],tempmin)
        sqrttable[temp[1]//sqrtnum] = tempmin
    else:
        tempmin = float("inf")
        if temp[1] % sqrtnum != 0:
            for ini in range(temp[1],sqrtnum * math.ceil(temp[1] / sqrtnum)):
                tempmin = min(tempmin,table[ini])
        for sqt in range(math.ceil(temp[1] / sqrtnum),math.floor(temp[2] / sqrtnum)+1):
            tempmin = min(sqrttable[sqt],tempmin)
        if temp[2] % sqrtnum != sqrtnum -1:
            for end in range(sqrtnum * (temp[2]//sqrtnum),temp[2]+1):
                tempmin = min(tempmin,table[end])
        print(tempmin)

Submission status: Wrong Answer

Solution code:
import math
num,query = (int(n) for n in input().split(' '))
table = [2**31 - 1 for n in range(num)]
sqrttable = []
sqrtnum = math.floor(math.sqrt(num))
tempmin = float("inf")
for t in range(num):
    if t % sqrtnum == sqrtnum - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    elif t == num - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    else:
        tempmin = min(table[t],tempmin)

for q in range(query):
    #print(sqrtnum,table,sqrttable)
    temp = [int(n) for n in input().split(' ')]
    if temp[0] == 0:
        table[temp[1]] = temp[2]
        tempmin = float("inf")
        for tm in range(sqrtnum*(temp[1]//sqrtnum),min(num,sqrtnum*(temp[1]//sqrtnum + 1))):
            tempmin = min(table[tm],tempmin)
        sqrttable[temp[1]//sqrtnum] = tempmin
    else:
        tempmin = float("inf")
        if temp[1] % sqrtnum != 0:
            for ini in range(temp[1],sqrtnum * math.ceil(temp[1] / sqrtnum)):
                tempmin = min(tempmin,table[ini])
        newtemp2 = temp[2] + 1
        for sqt in range(math.ceil(temp[1] / sqrtnum),newtemp2 // sqrtnum):
            tempmin = min(sqrttable[sqt],tempmin)
        if temp[2] % sqrtnum != sqrtnum -1:
            for end in range(sqrtnum * (temp[2]//sqrtnum),temp[2]+1):
                tempmin = min(tempmin,table[end])
        print(tempmin)

Submission status: Wrong Answer

Solution code:
import math
num,query = (int(n) for n in input().split(' '))
table = [2**31 - 1 for n in range(num)]
sqrttable = []
sqrtnum = math.floor(math.sqrt(num))
tempmin = float("inf")
for t in range(num):
    if t % sqrtnum == sqrtnum - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    elif t == num - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    else:
        tempmin = min(table[t],tempmin)

for q in range(query):
    #print(sqrtnum,table,sqrttable)
    temp = [int(n) for n in input().split(' ')]
    if temp[0] == 0:
        table[temp[1]] = temp[2]
        tempmin = float("inf")
        for tm in range(sqrtnum*(temp[1]//sqrtnum),min(num,sqrtnum*(temp[1]//sqrtnum + 1))):
            tempmin = min(table[tm],tempmin)
        sqrttable[temp[1]//sqrtnum] = tempmin
    else:
        tempmin = float("inf")
        if temp[1] % sqrtnum != 0:
            for ini in range(temp[1],min(temp[2],sqrtnum * math.ceil(temp[1] / sqrtnum))):
                tempmin = min(tempmin,table[ini])
        newtemp2 = temp[2] + 1
        for sqt in range(math.ceil(temp[1] / sqrtnum),newtemp2 // sqrtnum):
            tempmin = min(sqrttable[sqt],tempmin)
        if temp[2] % sqrtnum != sqrtnum -1 and temp[1] // sqrtnum != temp[2] // sqrtnum:
            for end in range(max(temp[1],sqrtnum * (temp[2]//sqrtnum)),temp[2]+1):
                tempmin = min(tempmin,table[end])
        print(tempmin)

Submission status: Wrong Answer

Solution code:
import math
num,query = (int(n) for n in input().split(' '))
table = [2**31 - 1 for n in range(num)]
sqrttable = []
sqrtnum = math.floor(math.sqrt(num))
tempmin = float("inf")
for t in range(num):
    if t % sqrtnum == sqrtnum - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    elif t == num - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    else:
        tempmin = min(table[t],tempmin)

for q in range(query):
    #print(sqrtnum,table,sqrttable)
    temp = [int(n) for n in input().split(' ')]
    if temp[0] == 0:
        table[temp[1]] = temp[2]
        tempmin = float("inf")
        for tm in range(sqrtnum*(temp[1]//sqrtnum),min(num,sqrtnum*(temp[1]//sqrtnum + 1))):
            tempmin = min(table[tm],tempmin)
        sqrttable[temp[1]//sqrtnum] = tempmin
    else:
        tempmin = float("inf")
        if temp[1] % sqrtnum != 0:
            for ini in range(temp[1],min(temp[2]+1,sqrtnum * math.ceil(temp[1] / sqrtnum))):
                tempmin = min(tempmin,table[ini])
        newtemp2 = temp[2] + 1
        for sqt in range(math.ceil(temp[1] / sqrtnum),newtemp2 // sqrtnum):
            tempmin = min(sqrttable[sqt],tempmin)
        if temp[2] % sqrtnum != sqrtnum -1 and temp[1] // sqrtnum != temp[2] // sqrtnum:
            for end in range(max(temp[1],sqrtnum * (temp[2]//sqrtnum)),temp[2]+1):
                tempmin = min(tempmin,table[end])
        print(tempmin)

Submission status: Wrong Answer

Solution code:
import math

def update(index,n):
    targ[index] = n
    index = (index - 1) // 2
    while True:
        targ[index] = min(targ[index],n)
        if index <= 0:
            break
        index = (index - 1) // 2

def find(i,e,node,inode,enode):
    #print(i,e,node,inode,enode)
    if inode > e or enode < i:
        return float("inf")
    elif (i <= inode and enode <= e) or inode==enode:
        return targ[node]

    else:
        irange = find(i,e,2*node + 1,inode,(inode+enode)// 2 )
        erange = find(i,e,2*node + 2,(inode+enode)//2 + 1,enode)
        return min(irange,erange)

num,query = (int(n) for n in input().split(' '))
initial = 2147483647
ln = 2 ** math.ceil(math.log2(num)) - 1
global targ
targ = [initial] * (ln + num)
length = num - 1

for q in range(query):
    #print(targ)
    temp = [int(n) for n in input().split(' ') ]
    if temp[0] == 0:
        update(temp[1] + ln,temp[2])
    else:
        print(find(temp[1],temp[2],0,0,length))