結果
| 問題 |
No.875 Range Mindex Query
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2024-03-05 04:17:07 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 817 bytes |
| コンパイル時間 | 5,051 ms |
| コンパイル使用メモリ | 308,972 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-29 17:47:31 |
| 合計ジャッジ時間 | 7,608 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#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;
}
umezo