// warm heart, wagging tail,and a smile just for you! // // ▒█████▒▒ // ██████████▒ // ▒████████████▒ // ██████████████████ // ████████████████████▒ // ▒██████████████████████▒ // ▒███████████████████████ // ▒████▒▒▒▒▒▒█████████████████▒ // ███▒▒▒▒▒▒██████████████████████▒▒▒ // ▒██▒▒███████████████████████▒▒▒▒▒██████ // ▒█████████████████████████▒▒▒▒▒▒█████████▒ // ▒█████████████████████▒▒▒▒▒▒██████████████ // ▒████ ████▒▒▒▒▒████ ████▒ // ▒█████▒ ████ ▒▒▒▒███████ ████ ██████▒ // ▒██▒▒▒▒▒ ██████ █████████ ██████ ██▒▒▒██▒ // █████████ ████████ █████████ ████████ ▒▒▒▒█████ // ▒█████████ ██████ ████████▒ ██████ █████████ // ▒██████████ ████ █████▒▒▒▒▒▒ ████ ██████████ // ████████████ ▒▒▒▒▒▒▒████████ ███████████▒ // ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒ // ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒ // ▒▒▒▒▒▒▒▒▒██████████████ ███████▒▒▒▒███████████ // █████████████████████████ ███████▒▒▒██████████████▒ // █████████████████████████████ ███████▒▒▒██████████████████▒ // ██████████████████████████████████████████████████████████████████████ // ██████████████████████████████████████████████████████████████████▒ // ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒ // #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 //#define MOD 998244353 const double EPS = 1e-9; #define INF (1LL<<60) #define D double #define fs first #define sc second #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i) #define REP(i,n) FOR(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair P; typedef vector vec; typedef vector> mat; template struct SegmentTree{ using F = function; int n; F f; T ti; vector dat; SegmentTree(){}; SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } void add(int k,T x){ dat[k+=n]+=x; while(k>>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ T vl=ti,vr=ti; for(int l=a+n,r=b+n;l>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } template int find(int a, int b, C &check, T x, int k=1, int l=0, int r=-1){ if(r<0)r=n; if(!check(f(x,dat[k]))||r<=a||b<=l)return -1; if(r-l==1)return l; int xl = find(a,b,check,x,(k<<1),l,(l+r)/2); if(xl>=0)return xl; x = f(x,dat[(k<<1)]); return find(a,b,check,x,(k<<1)|1,(l+r)/2,r); } template int find(int a, int b, C &check){ T x=ti; return find(a,b,check,x); } }; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n,q; cin >> n >> q; vector

a(n); REP(i,n) cin >> a[i].fs, a[i].sc = i; auto f = [](P a,P b){return min(a,b);}; SegmentTree

seg(f,P(INF,INF)); seg.build(a); REP(_,q){ int x,l,r; cin >> x >> l >> r; l--; r--; if(x == 1){ seg.update(l,P(a[r].fs,l)); seg.update(r,P(a[l].fs,r)); swap(a[l].fs,a[r].fs); } else{ cout << seg.query(l,r+1).sc+1 << "\n"; } } return 0; }