結果

問題 No.875 Range Mindex Query
ユーザー daku9640daku9640
提出日時 2019-09-06 22:10:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,222 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 41,500 KB
最終ジャッジ日時 2023-09-07 00:09:56
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from collections import deque
import numpy as np
def solve():
    n, q = map(int, input().split())
    A = np.asarray([0] + list(map(int, input().split())))
    M = []
    flg = True
    for _ in range(q):
        c, l, r = map(int, input().split())
        if c == 1:
            A[l], A[r] = A[r], A[l]
            flg = False
        else:
            if flg:
                x = [0, 0, 0, 0]
                for a, b, m in M:
                    if b < l or r < a:
                        continue
                    t = min(b, r) - max(a, l)
                    if x[0] < t:
                        x = [t, a, b, m]
                if x[0] != 0:
                    t, a, b, m = x
                    l2 = l + np.argmin(A[l:a])
                    r2 = b + np.argmin(A[b:r + 1])
                    z = min([A[l2], l2], [A[r2], r2], [A[m], m])
                    M.append([l, r, z[1]])
                    print(z[1])
                else:
                    m = l + np.argmin(A[l:r + 1])
                    M.append([l, r, m])
                    print(m)
            else:
                flg = True
                m = l + np.argmin(A[l:r + 1])
                M = [[l, r, m]]
                print(m)
solve()
0