結果

問題 No.875 Range Mindex Query
ユーザー ああいいああいい
提出日時 2021-12-05 16:30:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,247 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 39,296 KB
最終ジャッジ日時 2023-09-21 14:04:18
合計ジャッジ時間 19,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,024 KB
testcase_01 AC 23 ms
8,500 KB
testcase_02 AC 28 ms
8,148 KB
testcase_03 AC 17 ms
8,040 KB
testcase_04 AC 20 ms
8,076 KB
testcase_05 AC 20 ms
8,564 KB
testcase_06 AC 24 ms
8,612 KB
testcase_07 AC 24 ms
8,100 KB
testcase_08 AC 20 ms
8,552 KB
testcase_09 AC 20 ms
8,036 KB
testcase_10 AC 28 ms
8,512 KB
testcase_11 TLE -
testcase_12 AC 1,900 ms
24,208 KB
testcase_13 AC 1,678 ms
39,236 KB
testcase_14 AC 1,600 ms
37,732 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
権限があれば一括ダウンロードができます

ソースコード

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)
        
    """
    change(1,2)
    print(dat)
    """
0