comp-library

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

View the Project on GitHub luzhiled1333/comp-library

:heavy_check_mark: Template Header
(src/cpp-template/header/template-header.hpp)

競技用のテンプレートをすべて include したファイル。コンテスト中などは個別に include するのではなく、このファイルのみを include することにしている。

Depends on

Required by

Verified with

Code

#include "src/cpp-template/header/change-max.hpp"
#include "src/cpp-template/header/change-min.hpp"
#include "src/cpp-template/header/fast-ios.hpp"
#include "src/cpp-template/header/input.hpp"
#include "src/cpp-template/header/int-alias.hpp"
#include "src/cpp-template/header/io-set.hpp"
#include "src/cpp-template/header/make-vector.hpp"
#include "src/cpp-template/header/pair-ios.hpp"
#include "src/cpp-template/header/rep.hpp"
#include "src/cpp-template/header/size-alias.hpp"
#include "src/cpp-template/header/vector-ios.hpp"
#line 2 "src/cpp-template/header/change-max.hpp"

namespace luz {

  template < typename T1, typename T2 >
  inline bool chmax(T1 &a, T2 b) {
    return a < b and (a = b, true);
  }

} // namespace luz
#line 2 "src/cpp-template/header/change-min.hpp"

namespace luz {

  template < typename T1, typename T2 >
  inline bool chmin(T1 &a, T2 b) {
    return a > b and (a = b, true);
  }

} // namespace luz
#line 2 "src/cpp-template/header/fast-ios.hpp"

#include <iostream>

namespace luz {

  void set_fast_ios() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  }

} // namespace luz
#line 2 "src/cpp-template/header/input.hpp"

#line 2 "src/cpp-template/header/int-alias.hpp"

#include <cstdint>

namespace luz {

  using i32  = std::int32_t;
  using i64  = std::int64_t;
  using i128 = __int128_t;

  using u32  = std::uint32_t;
  using u64  = std::uint64_t;
  using u128 = __uint128_t;

} // namespace luz
#line 4 "src/cpp-template/header/input.hpp"

#line 6 "src/cpp-template/header/input.hpp"

namespace luz {

  template < typename T = i64 >
  T input() {
    T tmp;
    std::cin >> tmp;
    return tmp;
  }

} // namespace luz
#line 2 "src/cpp-template/header/io-set.hpp"

#line 2 "src/cpp-template/header/size-alias.hpp"

#include <cstddef>

namespace luz {

  using isize = std::ptrdiff_t;
  using usize = std::size_t;

} // namespace luz
#line 4 "src/cpp-template/header/io-set.hpp"

#include <iomanip>
#line 7 "src/cpp-template/header/io-set.hpp"

namespace luz {

  void io_set(usize precision) {
    std::cout << std::fixed << std::setprecision(precision);
    std::cerr << std::fixed << std::setprecision(precision);
  }

} // namespace luz
#line 2 "src/cpp-template/header/make-vector.hpp"

#line 4 "src/cpp-template/header/make-vector.hpp"

#include <vector>

namespace luz {

  template < typename T >
  std::vector< T > make_vector(usize a, T b) {
    return std::vector< T >(a, b);
  }

  template < typename... Ts >
  auto make_vector(usize a, Ts... ts) {
    return std::vector< decltype(make_vector(ts...)) >(
        a, make_vector(ts...));
  }

} // namespace luz
#line 2 "src/cpp-template/header/pair-ios.hpp"

#line 4 "src/cpp-template/header/pair-ios.hpp"
#include <utility>

namespace luz {

  template < typename T1, typename T2 >
  std::ostream &operator<<(std::ostream &os, std::pair< T1, T2 > p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
  }

  template < typename T1, typename T2 >
  std::istream &operator>>(std::istream &is, std::pair< T1, T2 > &p) {
    is >> p.first >> p.second;
    return is;
  }

} // namespace luz
#line 2 "src/cpp-template/header/rep.hpp"

#line 4 "src/cpp-template/header/rep.hpp"

#include <algorithm>

namespace luz {

  struct rep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept: i(i) {}
      void operator++() noexcept {
        ++i;
      }
      constexpr usize operator*() const noexcept {
        return i;
      }
      constexpr bool operator!=(const itr x) const noexcept {
        return i != x.i;
      }
    };
    const itr f, l;
    constexpr rep(const usize f, const usize l) noexcept
        : f(std::min(f, l)),
          l(l) {}
    constexpr auto begin() const noexcept {
      return f;
    }
    constexpr auto end() const noexcept {
      return l;
    }
  };

  struct rrep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept: i(i) {}
      void operator++() noexcept {
        --i;
      }
      constexpr usize operator*() const noexcept {
        return i;
      }
      constexpr bool operator!=(const itr x) const noexcept {
        return i != x.i;
      }
    };
    const itr f, l;
    constexpr rrep(const usize f, const usize l) noexcept
        : f(l - 1),
          l(std::min(f, l) - 1) {}
    constexpr auto begin() const noexcept {
      return f;
    }
    constexpr auto end() const noexcept {
      return l;
    }
  };

} // namespace luz
#line 2 "src/cpp-template/header/vector-ios.hpp"

#line 4 "src/cpp-template/header/vector-ios.hpp"

#line 7 "src/cpp-template/header/vector-ios.hpp"

namespace luz {

  template < typename T >
  std::ostream &operator<<(std::ostream &os,
                           const std::vector< T > vs) {
    for (usize i: rep(0, vs.size())) {
      os << vs[i] << (i + 1 != vs.size() ? " " : "");
    }
    return os;
  }

  template < typename T >
  std::istream &operator>>(std::istream &is, std::vector< T > &vs) {
    for (T &v: vs) {
      is >> v;
    }
    return is;
  }

} // namespace luz
#line 12 "src/cpp-template/header/template-header.hpp"
Back to top page