結果

問題 No.875 Range Mindex Query
ユーザー ああいいああいい
提出日時 2021-12-05 16:28:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,262 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 53,156 KB
最終ジャッジ日時 2023-09-21 14:03:41
合計ジャッジ時間 8,530 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 OLE -
testcase_11 OLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = list(map(int,input().split()))
a = list(map(int,input().split()))

n = 1
while n < N:
    n *= 2
C = N + 1
dat = [[C,C] for _ in range(2 * n - 1)]
for i in range(N):
    dat[i + n - 1][0] = a[i]
    dat[i + n - 1][1] = i

def calc(i):
    if dat[i * 2 + 1][0] < dat[i * 2 + 2][0]:
        dat[i][0] = dat[i * 2 + 1][0]
        dat[i][1] = dat[i * 2 + 1][1]
    else:
        dat[i][0] = dat[i * 2 + 2][0]
        dat[i][1] = dat[i * 2 + 2][1]
def make():
    for i in reversed(range(n-1)):
        calc(i)
def update(x,a):
    dat[x + n - 1][0] = a
    i = x + n - 1
    while i:
        i = (i-1) // 2
        calc(i)
def change(l,r):
    m1,m2 = dat[r + n - 1]
    update(r,dat[l + n - 1][0])
    update(l,m1)
def search(l,r,k = 0,a = 0,b = n):
    if b <= l or a >= r:
        return [C,C]
    if l <= a and b <= r:
        return dat[k]
    a1,i1 = search(l,r,k * 2 + 1,a, (a + b) // 2)
    a2,i2 = search(l,r,k * 2 + 2,(a + b) // 2,b)
    if a1 < a2:
        return [a1,i1]
    else:
        return [a2,i2]

make()
for _ in range(Q):
    
    s,l,r = list(map(int,input().split()))
    if s == 1:
        change(l-1,r-1)
    else:
        u,i = search(l-1,r)
        print(i + 1)
    print(dat)
        
    """
    change(1,2)
    print(dat)
    """
0