library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub sash2104/library

:heavy_check_mark: セグメント木、min (ac-library)
(test/ac-library/segtree.min.test.cpp)

Depends on

Code

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A"

#include <iostream>
#include "../../atcoder/segtree/min.hpp"
using namespace std;

// @title セグメント木、min (ac-library)
int main() {
  int n, q; cin >> n >> q;
  segtree::min::type<int> seg(n);
  for (int i = 0; i < q; ++i) {
    int c, x, y; cin >> c >> x >> y;
    if (c == 0) seg.set(x, y);
    else cout << seg.prod(x, y+1) << endl;
  }
}
#line 1 "test/ac-library/segtree.min.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A"

#include <iostream>
#line 2 "atcoder/segtree/min.hpp"

#include <atcoder/segtree>
#include <limits>

namespace segtree {
namespace min {
template<typename S>
S op(S a, S b) { return std::min(a, b); }
template<typename S>
S e() { return std::numeric_limits<S>::max();}
template<typename S>
using type = atcoder::segtree<S, op, e>;
} // namespace min
} // namespace segtree
#line 5 "test/ac-library/segtree.min.test.cpp"
using namespace std;

// @title セグメント木、min (ac-library)
int main() {
  int n, q; cin >> n >> q;
  segtree::min::type<int> seg(n);
  for (int i = 0; i < q; ++i) {
    int c, x, y; cin >> c >> x >> y;
    if (c == 0) seg.set(x, y);
    else cout << seg.prod(x, y+1) << endl;
  }
}
Back to top page