library

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

View the Project on GitHub gyouzasushi/library

:heavy_check_mark: test/aoj/DSL_2_A.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_A"
#include <iostream>

#include "datastructure/segtree.hpp"
#include "algebra/monoid_min.hpp"
int main() {
    int n, q;
    std::cin >> n >> q;
    segtree<monoid_min<int>> seg(n);
    while (q--) {
        int com, x, y;
        std::cin >> com >> x >> y;
        if (com == 0) {
            seg.set(x, y);
        } else {
            std::cout << seg.prod(x, y + 1) << '\n';
        }
    }
}
#line 1 "test/aoj/DSL_2_A.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_A"
#include <iostream>

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

#line 2 "algebra/concept.hpp"
#include <concepts>
template <class M>
concept semigroup = requires(typename M::S a, typename M::S b) {
    { M::op(a, b) } -> std::same_as<typename M::S>;
};
template <class M>
concept monoid = semigroup<M> && requires {
    { M::e() } -> std::same_as<typename M::S>;
};
template <class G>
concept group = monoid<G> && requires(typename G::S a) {
    { G::inv(a) } -> std::same_as<typename G::S>;
};
template <class A>
concept action = requires(typename A::F f, typename A::F g) {
    { A::composition(f, g) } -> std::same_as<typename A::F>;
    { A::id() } -> std::same_as<typename A::F>;
    { A::composition_commutative } -> std::convertible_to<bool>;
};
template <class A>
concept acted_monoid = monoid<A> && action<A> && requires(typename A::S x, typename A::F f) {
    { A::mapping(f, x) } -> std::same_as<typename A::S>;
};
template <class R>
concept semiring = requires(typename R::S a, typename R::S b) {
    { R::add(a, b) } -> std::same_as<typename R::S>;
    { R::zero() } -> std::same_as<typename R::S>;
    { R::mul(a, b) } -> std::same_as<typename R::S>;
    { R::one() } -> std::same_as<typename R::S>;
};
#line 5 "datastructure/segtree.hpp"
template <monoid M>
using segtree = atcoder::segtree<typename M::S, M::op, M::e>;
#line 2 "algebra/monoid_min.hpp"
#include <algorithm>
#include <limits>
template <class T>
struct monoid_min {
    using S = T;
    static S op(S a, S b) {
        return std::min(a, b);
    }
    static S e() {
        return std::numeric_limits<T>::max();
    }
};
#line 6 "test/aoj/DSL_2_A.test.cpp"
int main() {
    int n, q;
    std::cin >> n >> q;
    segtree<monoid_min<int>> seg(n);
    while (q--) {
        int com, x, y;
        std::cin >> com >> x >> y;
        if (com == 0) {
            seg.set(x, y);
        } else {
            std::cout << seg.prod(x, y + 1) << '\n';
        }
    }
}
Back to top page