結果

問題 No.875 Range Mindex Query
コンテスト
ユーザー daku9640
提出日時 2019-09-06 22:10:03
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 1,222 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 360 ms
コンパイル使用メモリ 20,960 KB
実行使用メモリ 43,108 KB
最終ジャッジ日時 2026-03-10 22:30:54
合計ジャッジ時間 13,788 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other RE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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