🌓
Ftt2333's Nest

我的缺省源

创建于 2022-08-07

Tags: OI

Categories: OI

献上代码!

Header

#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
void debug(...) {}
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define per(i, n) for (int i = (n) - 1; ~i; --i)
#define all(v) (v).begin(), (v).end()
using ll = long long;

int main() {
#ifndef LOCAL
  cin.tie(nullptr)->sync_with_stdio(false);
#endif
}

Debug

#ifndef MINE_DEBUG
#define MINE_DEBUG

#include <bits/stdc++.h>
using namespace std;

namespace debug_helper {

ostream& operator<<(ostream& os, __int128 x) {
  if (x >= 0) {
    if (x > 9) os << x / 10;
    os << char(x % 10 + 48);
  } else {
    os << '-';
    if (x < -9) os << -x / 10;
    os << char(48 - x % 10);
  }
  return os;
}
ostream& operator<<(ostream& os, unsigned __int128 x) {
  if (x > 9) os << x / 10;
  os << char(x % 10 + 48);
  return os;
}

template <class T1, class T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <size_t P, enable_if_t<P == 1>*, class... Args>
void tuple_helper(ostream& os, tuple<Args...> tp);
template <size_t P, enable_if_t<P != 1>*, class... Args>
void tuple_helper(ostream& os, tuple<Args...> tp);
template <class... Args>
ostream& operator<<(ostream& os, tuple<Args...> x) {
  os << '{';
  tuple_helper<tuple_size<tuple<Args...>>::value,
                nullptr, Args...>(os, x);
  return os << '}';
}

template <class T> void list_helper(ostream& os, T v);
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  list_helper(os, v); return os;
}
template <class T>
ostream& operator<<(ostream& os, list<T> v) {
  list_helper(os, v); return os;
}
template <class T>
ostream& operator<<(ostream& os, set<T> v) {
  list_helper(os, v); return os;
}
template <class T>
ostream& operator<<(ostream& os, multiset<T> v) {
  list_helper(os, v); return os;
}
template <class T>
ostream& operator<<(ostream& os, unordered_set<T> v) {
  list_helper(os, v); return os;
}
template <class T>
ostream& operator<<(ostream& os, unordered_multiset<T> v) {
  list_helper(os, v); return os;
}

template <class T> void map_helper(ostream& os, T v);
template <class T1, class T2>
ostream& operator<<(ostream& os, map<T1, T2> v) {
  map_helper(os, v); return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, unordered_map<T1, T2> v) {
  map_helper(os, v); return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, multimap<T1, T2> v) {
  map_helper(os, v); return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, unordered_multimap<T1, T2> v) {
  map_helper(os, v); return os;
}

template <class T>
void list_helper(ostream& os, T v) {
  os << '{';
  bool flag = true;
  for (auto x : v) {
    if (flag) flag = false;
    else os << ", ";
    os << x;
  }
  os << '}';
}
template <class T>
void map_helper(ostream& os, T v) {
  os << '{';
  bool flag = true;
  for (auto x : v) {
    if (flag) flag = false;
    else os << ", ";
    os << x.first << ": " << x.second;
  }
  os << '}';
}
template <size_t P, enable_if_t<P == 1>*, class... Args>
void tuple_helper(ostream& os, tuple<Args...> tp) {
  os << get<0>(tp);
}
template <size_t P, enable_if_t<P != 1>*, class... Args>
void tuple_helper(ostream& os, tuple<Args...> tp) {
  tuple_helper<P - 1, nullptr, Args...>(os, tp);
  os << ", " << get<P - 1>(tp);
}

template <class T> void debug(T x) { cerr << x; }
template <class T, class... Args>
void debug(T x, Args... args) {
  cerr << x << ", ";
  debug(args...);
}

}

#define debug(...) \
cerr << #__VA_ARGS__ " = ", \
debug_helper::debug(__VA_ARGS__), \
cerr << '\n'

#endif

Powered by Hexo, theme by Facter