diff --git a/.common/cpp/skeleton.cpp b/.common/cpp/skeleton.cpp index 26785f3..2699a76 100644 --- a/.common/cpp/skeleton.cpp +++ b/.common/cpp/skeleton.cpp @@ -1,18 +1,31 @@ #include +#include #include #include #include #include #include +#include #include +#include +#include #include #include #include +template +std::ostream &operator<<(std::ostream &s, std::pair const &p) { + return s << p.first << " " << p.second; +} + namespace helpers { using namespace std; +namespace math { + +static constexpr int32_t MODULO = 1000000007; + long pow(long base, long exp) { if (exp == 0) return 1; long half = pow(base, exp / 2); @@ -20,6 +33,27 @@ long pow(long base, long exp) { return half * half * base; } +} // namespace math + +namespace input { + +template +std::vector load_vector(std::size_t size) { + std::vector result{}; + + for (auto i = 0u; i < size; ++i) { + T x; + std::cin >> x; + result.push_back(std::move(x)); + } + + return result; +} + +} // namespace input + +namespace output { + template inline void answer(const T &ans) { cout << ans << "\n"; @@ -28,9 +62,28 @@ inline void answer(const T &ans) { inline void yes() { cout << "YES\n"; } inline void no() { cout << "NO\n"; } +inline void yesno(bool ans) { + if (ans) { + yes(); + } else { + no(); + } +} + +} // namespace output + +using namespace math; +using namespace input; +using namespace output; + +#define LOOP(n) for (auto i = 0; i < n; ++i) + } // namespace helpers -namespace { +// for ‹N› test cases, uncomment for single test case +// #define SINGLE + +namespace solution { using namespace std; using namespace helpers; @@ -39,10 +92,9 @@ void solve() { // TODO } -} // namespace +} // namespace solution -// for single test case, comment out for ‹N› test cases -#define SINGLE +using namespace solution; #ifdef TEST @@ -58,7 +110,7 @@ int main(void) { #ifdef SINGLE - solve(); + solution::solve(); #else @@ -67,7 +119,7 @@ int main(void) { std::cin >> N >> std::ws; for (auto i = 0; i < N; ++i) { - solve(); + solution::solve(); } #endif