update template and debugger

This commit is contained in:
ShazidMahsrafi 2024-04-30 16:50:37 +06:00
parent 8f472939de
commit cfcd860bf0
2 changed files with 32 additions and 29 deletions

View File

@ -1,28 +1,32 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
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"<<endl
#define no cout<<"NO"<<endl
#define FAST (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=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 "<<TC<<": ";
solve();
}
}

31
debug.h
View File

@ -3,8 +3,7 @@ namespace __DEBUG_UTIL__
{
using namespace std;
template <typename T>
concept is_iterable = requires(T &&x) { begin(x); } &&
!is_same_v<remove_cvref_t<T>, string>;
concept is_iterable = requires(T &&x) { begin(x); } && !is_same_v<remove_cvref_t<T>, 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<bool> 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 <typename T>
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 <typename T, typename... V>
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__)
#define dbg(...) std::cerr << __LINE__ << ": ", __DEBUG_UTIL__::printer(#__VA_ARGS__, __VA_ARGS__)
#define dbgArr(...) std::cerr << __LINE__ << ": ", __DEBUG_UTIL__::printerArr(#__VA_ARGS__, __VA_ARGS__)