// g++ -g program.cpp -o program.exe -D _DEBUG && .\program.exe #include #include using namespace std; // TYPE ABBREVIATIONS using ll = long long; typedef pair pi; typedef pair pl; typedef pair ps; typedef vector vi; typedef vector vl; typedef vector vb; typedef vector vs; typedef vector vpi; typedef vector vpl; typedef vector vps; typedef vector vvi; typedef vector vvl; typedef vector vvs; // INFINITIES const int INF = 1 << 30; const ll INFl = 1LL << 60; // DATA STRUCT ABBREVIATIONS #define pb push_back #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sortUp(x) sort(all(x)) #define sortDn(x) reverse(all(x)) #define uniqfy(x) sort(all(x));x.erase(unique(all(x)),end(x)) // LOOP ABBREVIATIONS #define rep1(n) for (int i=0; i void debug(T val) { #ifdef _DEBUG cout << "DEBUG: " << val << endl; #endif } template void debugVector(vector vec) { #ifdef _DEBUG rep(i, vec.size()-1) { cout << vec[i] << ", "; } cout << vec[vec.size()-1] << endl; // don't display last comma #endif } void debugSetup() { #ifdef _DEBUG freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); debug("[Start]"); gettimeofday(&runtimeTimer[0], NULL); #endif } void debugUnset() { #ifdef _DEBUG gettimeofday(&runtimeTimer[1], NULL); float runtimeMilli = ((float)(runtimeTimer[1].tv_usec - runtimeTimer[0].tv_usec)) / 1000; debug("[Runtime: " + to_string(runtimeMilli) + " milliseconds]"); #endif } // IO MACROS #define el "\n" // std::endl is slow #define spc " " // @sorachandu template T nxt() { T x; cin >> x; return x; } template vector nxlst(int n) { vector lst; rep(i, n) { lst.pb(nxt()); } return lst; } template vector> nxmtx(int y, int x) { vector> mtx; rep(i, y) { vector lst = nxlst(x); mtx.pb(lst); } return mtx; // first idx y value, second idx x value } // IDK BUT ITS HERE IG bool sortByFi(pi p, pi q) { return (p.fi < q.fi); } bool sortBySe(pi p, pi q) { return (p.se < q.se); } // DATA STRUCTURES class UnionFind { private: vi _size; vi _parent; public: UnionFind(int n) { _size = vector(n, 1); _parent = vector(n, -1); } int find(int v) { if (_parent[v] == -1) { return v; } else { vi verts; while (_parent[v] >= 0) { verts.pb(v); v = _parent[v]; } for (int i : verts) { _parent[i] = v; } return v; } } bool merge(int x, int y) { x = find(x); y = find(y); if (x == y) { return false; } if (_size[x] < _size[y]) { x, y = y, x; } _parent[y] = x; _size[x] = _size[x] + _size[y]; return true; } vi allSets() { unordered_set sets; rep(i, _parent.size()) { sets.insert(find(i)); } return vi(all(sets)); } bool same(int x, int y) { x = find(x); y = find(y); return x == y; } int size(int x) { return _size[find(x)]; } }; int main() { debugSetup(); cout << "Hello World!" << el; debugUnset(); return 0; }