Hi! I'd like to share with the community the template I use for competing in Codeforces rounds. It's very simple, so is easier to learn to use it.
I hope it helps someone :-)
#include <bits/stdc++.h>
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for(int i=a;i<b;++i)
#define all(x) x.begin(), x.end()
#define sz(v) (int)(v.size())
#define feq(a, b) (fabs(a - b) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
const ll INF = 1e18, MOD = 1e9+7;
const int int_max = 1e9;
const ld eps = 1e-9;
void solve() {
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
int T = 1;
cin>>T;//You can comment this if you don't need it
while(T--) {
solve();
}
}
A couple things I would like to point out as improvements or just changes you could make. note these are just my ideas, not yours so you don't have to use them.
The above code works the same as what you have written but in one line. how it works is dark magic and I won't bother explaining it.
The above code are just some ways to approach constants
The above code is just something for doubles.
there is a danger of things going wrong with vec.size() since its an unsigned integer so this is a nice way to wrap it up.
you can also add macros/lines of code for better random and uid. a few other things I personally have, 2 macros for memsetting an entire array and memsetting to a certain size (good for multitest). i also have 2 macros LC(k) to (k*2 +1) and RC(k) to (k*2 + 2) for my segtree. this can be put into snippets if you want. i also just have a thing for putting return 0 at the end :).
so there are my thoughts, you are welcome to do as you wish with them
Auto comment: topic has been updated by PathToMaster (previous revision, new revision, compare).
Auto comment: topic has been updated by PathToMaster (previous revision, new revision, compare).