結果

問題 No.875 Range Mindex Query
ユーザー umezoumezo
提出日時 2024-03-05 04:17:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 11,070 ms
コンパイル使用メモリ 308,332 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-05 04:17:21
合計ジャッジ時間 13,349 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 49 ms
6,676 KB
testcase_12 AC 39 ms
6,676 KB
testcase_13 AC 35 ms
6,676 KB
testcase_14 AC 39 ms
6,676 KB
testcase_15 AC 48 ms
6,676 KB
testcase_16 AC 51 ms
6,676 KB
testcase_17 AC 54 ms
6,676 KB
testcase_18 AC 52 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;

const int INF=1e9;
int op(int x,int y){return min(x,y);}
int e(){return INF;}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,q;
  cin>>n>>q;
  vector<int> A(n),B(n);
  rep(i,n){
    cin>>A[i];
    A[i]--;
    B[A[i]]=i;
  }
  segtree<int,op,e> seg(A);
  while(q--){
    int c;
    cin>>c;
    if(c==1){
      int l,r;
      cin>>l>>r;
      l--,r--;
      int a=seg.get(l),b=seg.get(r);
      seg.set(l,b),seg.set(r,a);
      B[a]=r,B[b]=l;
    }
    else{
      int l,r;
      cin>>l>>r;
      l--,r--;
      auto c=seg.prod(l,r+1);
      cout<<B[c]+1<<'\n';
    }
  }
    
  return 0;
}
0