From 1e83036c3ff40310af6cf0d915ad1621d2eeeb83 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sat, 30 Sep 2023 14:51:08 +0300 Subject: Separated templates for debugging in a separate file --- algo/debug.h | 123 +++++++++++++++++++++++++++++++++++++++++++ contests/Round900/B/main.cpp | 4 +- 2 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 algo/debug.h diff --git a/algo/debug.h b/algo/debug.h new file mode 100644 index 0000000..f7b1a0b --- /dev/null +++ b/algo/debug.h @@ -0,0 +1,123 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpii = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int mod = (int)1e9 + 7; +const db pi = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "["; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "]"; + return os; +} + +template +ostream &operator<<(ostream &os, const vector> &vec) { + os << "[\n"; + for (size_t i = 0; i < vec.size(); ++i) { + os << " " << vec[i]; + if (i > 0) + os << ", "; + os << '\n'; + } + os << "]"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void debug_out() { cerr << endl; } + +template void debug_out(head h, tail... t) { + cerr << h << '\n'; + debug_out(t...); +} + +#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):\n", debug_out(__VA_ARGS__) diff --git a/contests/Round900/B/main.cpp b/contests/Round900/B/main.cpp index 3484ecd..a77ceb3 100755 --- a/contests/Round900/B/main.cpp +++ b/contests/Round900/B/main.cpp @@ -120,9 +120,9 @@ void solve() { int n; cin >> n; vi v(n); - v[0] = 3; + v[0] = 5; for (int i = 1; i < n; i++) { - v[i] = v[i - 1] + 7; + v[i] = v[i - 1] + 1; } for (int i = 0; i < n; i++) { cout << v[i] << ' '; -- cgit v1.2.3