diff --git a/include.hh b/include.hh index 95acfe2..7662cef 100644 --- a/include.hh +++ b/include.hh @@ -7,10 +7,7 @@ */ #include -#include using namespace std; -using namespace __gnu_cxx; -using namespace __gnu_pbds; /* macro helpers */ #define __NARGS(...) std::tuple_size::value @@ -128,7 +125,22 @@ template void __read(T& x, U&... args) { cin >> x; __ #define putvec(a) __AS_PROCEDURE(for (auto&& x : a) cout << x << ' '; cout << endl;) #define debug(x) __AS_PROCEDURE(cerr << #x" = " << (x) << endl;) #define debugvec(a) __AS_PROCEDURE(cerr << #a" = "; for (auto&& x : a) cerr << x << ' '; cerr << endl;) -template ostream& operator<<(ostream& out, vector vec) { +template ostream& operator<<(ostream& out, const pair& p) { + out << "{" << p.first << ", " << p.second << "}"; + return out; +} +template +void print_tuple_impl(std::basic_ostream& os, const Tuple& t, std::index_sequence) { + using swallow = int[]; // guaranties left to right order + (void)swallow { 0, (void(os << (Index == 0 ? "" : ", ") << std::get(t)), 0)... }; +} +template +decltype(auto) operator<<(std::basic_ostream& os, const std::tuple& t) { + os << "{"; + print_tuple_impl(os, t, std::index_sequence_for{}); + return os << "}"; +} +template ostream& operator<<(ostream& out, const vector& vec) { for (auto&& i : vec) out << i << ' '; return out; }