-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.cpp
189 lines (180 loc) · 4.38 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
* Author : Jubayer Abdullah Joy
* CSE, 5th Batch, University of Barishal
* Mail : [email protected]
* Codeforces : Joy
* Github : github.com/JubayerJoy
* Problem :
*
*/
#pragma GCC optimize("Ofast", "omit-frame-pointer", "inline", "unroll-loops", "fast-math", "no-stack-protector")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper") //Enable AVX
#pragma GCC target("sse", "sse2", "sse3", "sse4", "popcnt", "abm", "mmx", "avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#ifdef Joy
#define io
#define D(args...) \
do \
{ \
cerr << "DEBUG > Line : " << __LINE__ << " > " << #args << " : "; \
dbg(args); \
} while (0)
#else
#define io \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define D(args...)
#endif
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a) * ((b) / gcd(a, b))
#define f(i, n) for (ll i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(all(v))
#define rev(v) reverse(all(v))
#define bitcount __builtin_popcountll
#define YES outln("YES")
#define NO outln("NO")
#define spc " "
#define el "\n"
#define die return 0
/*** Careful, under construction ***/
#define _T template <typename T, typename... Types>
#define _Tos template <typename T> \
ostream &operator
#define _Tfs template <typename F, typename S> \
ostream &operator
auto sum()
{
return 0;
}
_T auto sum(T a, Types... b) { return (a) + sum(b...); }
auto product() { return 1; }
_T auto product(T a, Types... b) { return (a)*product(b...); }
void in() { return; }
_T void in(T &a, Types &... b)
{
cin >> (a);
in(b...);
}
void out() { return; }
_T void out(T a, Types... b)
{
cout << (a);
out(b...);
}
void outln()
{
cout << el;
return;
}
_T void outln(T a, Types... b)
{
cout << (a);
outln(b...);
}
void dbg() { cerr << el; }
_T void dbg(T a, Types... b)
{
cerr << (a) << ' ';
dbg(b...);
}
_Tos << (ostream & os, vector<T> &v)
{
for (auto i : v)
os << (i) << spc;
return os << el;
}
_Tos << (ostream & os, set<T> &v)
{
for (auto i : v)
os << (i) << spc;
return os << el;
}
_Tos << (ostream & os, multiset<T> &v)
{
for (auto i : v)
os << (i) << spc;
return os << "\n";
}
_Tos << (ostream & os, unordered_set<T> &v)
{
for (auto i : v)
os << (i) << spc;
return os << "\n";
}
_Tos << (ostream & os, stack<T> &v)
{
while (!v.empty())
{
os << (v.top()) << spc;
v.pop();
}
return os << el;
}
_Tos << (ostream & os, priority_queue<T> &v)
{
while (!v.empty())
{
os << (v.top()) << spc;
v.pop();
}
return os << el;
}
_Tos << (ostream & os, queue<T> &v)
{
while (!v.empty())
{
os << (v.front()) << spc;
v.pop();
}
return os << el;
}
_Tfs << (ostream & os, pair<F, S> &p) { return os << "\n(" << (p.first) << ", " << (p.second) << ")"; }
_Tfs << (ostream & os, map<F, S> &v)
{
for (auto i : v)
os << el << (i.first) << " = " << (i.second);
return os << el;
}
_Tfs << (ostream & os, multimap<F, S> &v)
{
for (auto i : v)
os << el << (i.first) << " = " << (i.second);
return os << el;
}
_Tfs << (ostream & os, unordered_map<F, S> &v)
{
for (auto i : v)
os << el << (i.first) << " = " << (i.second);
return os << el;
}
/*** Movement ***/
#define valid(new_x, new_y, row, column) (new_x) >= 0 && (new_x) < (row) && (new_y) >= 0 && (new_y) < (column)
//vi fx={+1,-1,+0,+0}; // Four Direction
//vi fy={+0,+0,+1,-1}; // Four Direction
//vi fx={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move - 8 Direction
//vi fy={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move - 8 Direction
//vi fx={-2,-2,-1,-1,+1,+1,+2,+2}; // Knights Move
//vi fy={-1,+1,-2,+2,-2,+2,-1,+1}; // Knights Move
//vector<vi> matrix(row, vi (column,value)); //- 2D Vector
//cout << fixed << setprecision(20)<< value <<endl;
//sort(all(a), greater <int>());
int main(int argc, char const *argv[])
{
io
return 0;
}