結果
| 問題 | 
                            No.875 Range Mindex Query
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yuliicppy
                         | 
                    
| 提出日時 | 2019-09-06 22:13:53 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,887 bytes | 
| コンパイル時間 | 1,038 ms | 
| コンパイル使用メモリ | 100,336 KB | 
| 実行使用メモリ | 8,704 KB | 
| 最終ジャッジ日時 | 2024-06-24 18:38:18 | 
| 合計ジャッジ時間 | 3,192 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 7 WA * 11 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;
#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
//#define int long long
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}
const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
VI A(1123456,INF);
template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
  int sz;
  vector< Monoid > seg;
  const F f;
  const Monoid M1;
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};
signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q; cin >> N >> Q;
    REP(i,N) cin >> A[i];
    SegmentTree<int> seg(N,[](int a, int b){
        if(A[a] < A[b]) return a;
        else return b;
    },0);
    REP(i,N){
        seg.set(i,i);
    }
    seg.build();
    REP(i,Q){
        int a,b,c; cin >> a >> b >> c;
        b--; c--;
        if(a == 1){
            //swap(A[b],A[c]);
            int tmp = A[c];
            A[c] = A[b];
            A[b] = tmp;
            seg.update(b,b);
            seg.update(c,c);
        }else{
            cout << seg.query(b,c+1)+1 << endl;
        }
    }
}
            
            
            
        
            
yuliicppy