Codeforces/.common/cpp/skeleton.cpp

236 lines
4.6 KiB
C++
Raw Normal View History

#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#pragma region helpers
#pragma region aliases
#define LOOP(var, n) for (auto var = 0; var < n; ++var)
template <typename T>
using V = std::vector<T>;
template <typename K, typename V>
using M = std::map<K, V>;
template <typename T>
using S = std::set<T>;
template <typename T>
using Q = std::deque<T>;
using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
#pragma endregion /* aliases */
#pragma region data structures
template <typename T>
struct max_heap {
using container = std::vector<T>;
typename container::size_type size() const { return h.size(); }
void push(T item) {
h.push_back(item);
std::push_heap(h.begin(), h.end());
}
T pop() {
std::pop_heap(h.begin(), h.end());
T item = std::move(h.back());
h.pop_back();
return item;
}
private:
container h;
};
template <typename T>
struct min_heap {
using container = std::vector<T>;
typename container::size_type size() const { return h.size(); }
void push(T item) {
h.push_back(item);
std::push_heap(h.begin(), h.end(), std::greater<>{});
}
T pop() {
std::pop_heap(h.begin(), h.end(), std::greater<>{});
T item = std::move(h.back());
h.pop_back();
return item;
}
private:
container h;
};
#pragma endregion /* data structures */
#pragma region debug
void dbg_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
std::cerr << ' ' << H;
dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) \
std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
<< "):", \
dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
#pragma endregion debug
#pragma region functional
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template <class Fun>
class y_combinator_result {
Fun fun_;
public:
template <class T>
explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
template <class... Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template <class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
#pragma endregion /* functional */
#pragma region input
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
#pragma endregion /* input */
#pragma region math
static constexpr std::int32_t MODULO = 1000000007;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
#pragma endregion /* math */
#pragma region output
template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, std::pair<T, U> const &p) {
return os << p.first << " " << p.second;
}
template <typename C, typename T = typename std::enable_if<
!std::is_same<C, std::string>::value,
typename C::value_type>::type>
std::ostream &operator<<(std::ostream &os, const C &v) {
std::string sep;
for (const T &x : v) {
os << sep << x, sep = " ";
}
return os;
}
template <typename T>
inline void answer(const T &ans) {
std::cout << ans << "\n";
}
inline void yes() { std::cout << "YES\n"; }
inline void no() { std::cout << "NO\n"; }
inline void yesno(bool ans) { std::cout << (ans ? "YES" : "NO") << "\n"; }
#pragma endregion /* output */
#pragma endregion /* helpers */
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
void solve() {
// TODO
dbg("Hello from debug");
answer("Hello");
}
void tests() {
// TODO
}
} // namespace solution
using namespace solution;
#ifdef TEST
int main(void) {
tests();
return 0;
}
#else
int main(void) {
int N = 1;
#ifndef SINGLE
std::cin >> N;
#endif
while (N-- > 0) {
solve();
}
return 0;
}
#endif