-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.cpp
127 lines (105 loc) · 3.11 KB
/
template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// template.cpp
// Created by David del Val on 05/07/2021
//
//
// https://github.com/Ddelval/Competitive-programming/blob/master/template.cpp
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#ifdef DEBUG
#define db(x) x
#define echo(x) cout << #x << ": " << x << endl;
#else
#define db(x)
#define echo(x)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
template <typename T, typename Q>
inline ostream &operator<<(ostream &o, pair<T, Q> p);
// ====================================================== //
// =================== Container IO =================== //
// ====================================================== //
template <bool B, typename T = void>
using Enable_if = typename std::enable_if<B, T>::type;
struct subs_fail {};
template <typename T> struct subs_succeeded : std::true_type {};
template <> struct subs_succeeded<subs_fail> : std::false_type {};
template <typename T> struct get_iter_res {
private:
template <typename X> static auto check(X const &x) -> decltype(x.begin());
static subs_fail check(...);
public:
using type = decltype(check(std::declval<T>()));
};
template <typename T>
struct Has_iterator : subs_succeeded<typename get_iter_res<T>::type> {};
template <> struct Has_iterator<string> : subs_fail {};
constexpr const char *sep1 = " ";
constexpr const char *sep2 = "\n";
template <typename T> struct get_termination {
static constexpr const char *get() { return sep1; }
};
template <typename U, typename S> struct get_termination<vector<U, S>> {
static constexpr const char *get() { return sep2; }
};
template <typename T>
Enable_if<Has_iterator<T>::value, ostream &> operator<<(ostream &o, T val) {
bool first = true;
for (auto it = val.begin(); it != val.end(); ++it) {
if (!first) {
constexpr const char *terminator =
get_termination<typename T::value_type>::get();
o << terminator;
}
first = false;
o << *it;
}
return o;
}
template <typename T = ll> inline vector<T> readVector(int size) {
vector<T> v;
v.reserve(size);
T a;
for (int i = 0; i < size; ++i) {
cin >> a;
v.push_back(a);
}
return v;
}
// ====================================================== //
// ================== Pairs operations ================== //
// ====================================================== //
inline pii operator+(pii a, pii b) { return {a.fi + b.fi, a.se + b.se}; }
template <typename T, typename Q>
inline ostream &operator<<(ostream &o, pair<T, Q> p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
// gcd(0, n) = n
inline long long _gcd(long long a, long long b) {
while (b)
b %= a ^= b ^= a ^= b;
return a;
}
ll inf = LLONG_MAX / 10;
int iinf = INT_MAX / 10;
#ifdef _LOCAL_
// Local constraints
#else
// Judge constraints
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
return 0;
}