結果

問題 No.875 Range Mindex Query
ユーザー ooaiu
提出日時 2024-11-14 12:28:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 3,646 ms
コンパイル使用メモリ 281,572 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 12:29:04
合計ジャッジ時間 5,712 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

#include <atcoder/segtree>
void solve() {
    int N, Q;
    cin >> N >> Q;
    vector<pair<int, int>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].first;
        A[i].second = i;
    }
    atcoder::segtree<pair<int, int>, [](const pair<int, int>& a, const pair<int, int>& b) -> pair<int, int> { return min(a, b); }, []() -> pair<int, int> { return {1e9, 1e9}; }>
        seg(A);
    while (Q--) {
        int t;
        cin >> t;
        int l, r;
        cin >> l >> r;
        if (t == 1) {
            l--; r--;
            pair<int, int> L = seg.get(l);
            pair<int, int> R = seg.get(r);
            swap(L.second, R.second);
            seg.set(l, R);
            seg.set(r, L);
        } else {
            l--;
            auto ans = seg.prod(l, r);
            cout << ans.second + 1 << endl;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0