結果

問題 No.875 Range Mindex Query
コンテスト
ユーザー harurun
提出日時 2026-04-01 03:10:42
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,518 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,728 ms
コンパイル使用メモリ 578,388 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2026-04-01 03:10:59
合計ジャッジ時間 9,652 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef ONLINE_JUDGE
#include "header.hpp"
#else
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using cpp_int=boost::multiprecision::cpp_int;
#include <boost/multiprecision/cpp_dec_float.hpp>
template<unsigned size>using cpp_float=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size>>;
template<unsigned size>using cpp_double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size,long long>>;
#endif

using namespace std;
using ll=long long;
inline void yn(bool x){if(x){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
#define double_out(x) fixed << setprecision(x)
template<class T> inline void erase_duplicate(vector<T>& A){sort(A.begin(),A.end());A.erase(unique(A.begin(),A.end()),A.end());}
inline ll powll(ll x,ll n){ll r=1;while(n>0){if(n&1){r*=x;};x*=x;n>>=1;};return r;}

struct S{
    ll val;
    ll index;
};

S op(S a, S b){
    if(a.val>b.val){
        return b;
    }else{
        return a;
    }
}

S e(){
    return S{(ll)1e9,-1};
}

int main(){
    ll N,Q;
    cin>>N>>Q;
    vector<S> A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i].val;
        A[i].index=i;
    }
    atcoder::segtree<S,op,e> seg(A);
    for(ll i=0;i<Q;i++){
        ll t,l,r;
        cin>>t>>l>>r;
        l--;
        r--;
        if(t==1){
            S L=seg.get(l);
            S R=seg.get(r);
            seg.set(l,S{R.val,l});
            seg.set(r,S{L.val,r});
        }else{
            cout<<seg.prod(l,r+1).index+1<<endl;
        }
    }
}

0