#pragma GCC optimize("O3") #include using namespace std; using ll=long long; using P=pair; template using V=vector; #define fi first #define se second #define all(v) (v).begin(),(v).end() const ll inf=(1e18); const ll mod=1000000007; ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;} ll lcm(ll c,ll d){return c/gcd(c,d)*d;} struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout< bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } template struct seg{ int n; using F=function; F f; Monoid t; V dat; seg(int n_,F f,Monoid t):f(f),t(t){ n=1; while(n=0;i--)dat[i]=f(dat[i*2+1],dat[i*2+2]); } seg(int n_,vector &v,F f,Monoid t):f(f),t(t){ n=1; while(n=0;i--)dat[i]=f(dat[i*2+1],dat[i*2+2]); } void update(int i,Monoid x){ //葉のノード番号 i+=n-1; dat[i]=x; //登りながら更新(n1=(n-1)/2,n2=(n1-1)/2...と計算すると親のノードを調べることができ最終的に根に到達する) while(i>0){ i=(i-1)/2; //配置の更新 dat[i]=f(dat[i*2+1],dat[i*2+2]); } } //区間[a,b)の最小値、l,rにはノードkに対応づく区間を与える Monoid query(int a,int b,int k=0,int l=0, int r=-1){ if(r<0)r=n; //区間が交差するかどうか、しなければINT_MAX if(r<=a||l>=b)return t; //区間を完全に含んでいるか、含んでいたら節点の値 if(a<=l&&r<=b)return dat[k]; else{ //上記を満たさなければ2分法で探す P vl=query(a,b,k*2+1,l,(l+r)/2); P vr=query(a,b,k*2+2,(l+r)/2,r); return f(vl,vr); } } }; int main(){ ll n,q; cin>>n>>q; auto f=[](P a,P b){return min(a,b);}; V

dat(n); for(int i=0;i>dat[i].fi; dat[i].se=i+1; } seg

tree(n,dat,f,{INT_MAX,INT_MAX}); int c; while(q--){ cin>>c; if(c==2){ int s,t; cin>>s>>t; s--;t--; cout<>s>>t; s--;t--; P l=tree.query(s,s+1); P r=tree.query(t,t+1); swap(l.se,r.se); tree.update(s,r); tree.update(t,l); } } }