結果
問題 |
No.875 Range Mindex Query
|
ユーザー |
![]() |
提出日時 | 2024-03-05 04:30:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 843 bytes |
コンパイル時間 | 5,262 ms |
コンパイル使用メモリ | 311,316 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 17:47:39 |
合計ジャッジ時間 | 6,732 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; struct S{ int a,i; }; const int INF=1e9; S op(S x,S y){ if(x.a<y.a) return x; return y; } S e(){return S{INF,-1};} int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,q; cin>>n>>q; vector<S> A(n); rep(i,n){ int a; cin>>a; A[i]=S{a,i}; } segtree<S,op,e> seg(A); while(q--){ int c; cin>>c; if(c==1){ int l,r; cin>>l>>r; l--,r--; auto a=seg.get(l),b=seg.get(r); seg.set(l,S{b.a,l}),seg.set(r,S{a.a,r}); } else{ int l,r; cin>>l>>r; l--,r--; auto c=seg.prod(l,r+1); cout<<c.i+1<<'\n'; } } return 0; }