From cfcd860bf0d27c3bc137a4143c7a1b933e2df579 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Tue, 30 Apr 2024 16:50:37 +0600 Subject: [PATCH] update template and debugger --- CPTemp.cpp | 30 +++++++++++++++++------------- debug.h | 31 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/CPTemp.cpp b/CPTemp.cpp index 9bec91d..3319364 100644 --- a/CPTemp.cpp +++ b/CPTemp.cpp @@ -1,28 +1,32 @@ -#include +#include using namespace std; #ifdef ONLINE_JUDGE - #define dbg(...) +#define dbg(...) #else - #include "debug.h" +#include "debug.h" #endif -#define ll long long -#define endl '\n' -#define all(x) x.begin(), x.end() -#define sz(x) (int)(x).size() -#define yes cout<<"YES"<>=1;}return ans;} void solve() { - + } signed main() { FAST; - int TC = 1; + int TCS = 1; // cin >> TC; - while (TC--) solve(); + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< - concept is_iterable = requires(T &&x) { begin(x); } && - !is_same_v, string>; + concept is_iterable = requires(T &&x) { begin(x); } && !is_same_v, string>; void print(const char *x) { cerr << x; } void print(char x) { cerr << "\'" << x << "\'"; } void print(bool x) { cerr << (x ? "T" : "F"); } @@ -13,10 +12,10 @@ namespace __DEBUG_UTIL__ { /* Overloaded this because stl optimizes vector by using _Bit_reference instead of bool to conserve space. */ int f = 0; - cerr << '{'; + cerr << '['; for (auto &&i : v) cerr << (f++ ? "," : "") << (i ? "T" : "F"); - cerr << "}"; + cerr << "]"; } template void print(T &&x) @@ -35,23 +34,23 @@ namespace __DEBUG_UTIL__ else { /* Normal Iterable */ int f = 0; - cerr << "{"; + cerr << "["; for (auto &&i : x) cerr << (f++ ? "," : ""), print(i); - cerr << "}"; + cerr << "]"; } else if constexpr (requires { x.pop(); }) /* Stacks, Priority Queues, Queues */ { auto temp = x; int f = 0; - cerr << "{"; + cerr << "["; if constexpr (requires { x.top(); }) while (!temp.empty()) cerr << (f++ ? "," : ""), print(temp.top()), temp.pop(); else while (!temp.empty()) cerr << (f++ ? "," : ""), print(temp.front()), temp.pop(); - cerr << "}"; + cerr << "]"; } else if constexpr (requires { x.first; x.second; }) /* Pair */ { @@ -80,9 +79,9 @@ namespace __DEBUG_UTIL__ cerr.write(names, i) << " = "; print(head); if constexpr (sizeof...(tail)) - cerr << " || ", printer(names + i + 1, tail...); + cerr << " | ", printer(names + i + 1, tail...); else - cerr << "]\n"; + cerr << "\n"; } template void printerArr(const char *names, T arr[], size_t N, V... tail) @@ -92,16 +91,16 @@ namespace __DEBUG_UTIL__ cerr << names[i]; for (i++; names[i] and names[i] != ','; i++) ; - cerr << " = {"; + cerr << " = ["; for (size_t ind = 0; ind < N; ind++) cerr << (ind ? "," : ""), print(arr[ind]); - cerr << "}"; + cerr << "]"; if constexpr (sizeof...(tail)) - cerr << " || ", printerArr(names + i + 1, tail...); + cerr << " | ", printerArr(names + i + 1, tail...); else - cerr << "]\n"; + cerr << "\n"; } } -#define dbg(...) std::cerr << __LINE__ << ": [", __DEBUG_UTIL__::printer(#__VA_ARGS__, __VA_ARGS__) -#define dbgArr(...) std::cerr << __LINE__ << ": [", __DEBUG_UTIL__::printerArr(#__VA_ARGS__, __VA_ARGS__) \ No newline at end of file +#define dbg(...) std::cerr << __LINE__ << ": ", __DEBUG_UTIL__::printer(#__VA_ARGS__, __VA_ARGS__) +#define dbgArr(...) std::cerr << __LINE__ << ": ", __DEBUG_UTIL__::printerArr(#__VA_ARGS__, __VA_ARGS__) \ No newline at end of file