Disclaimer:
I am a beginner in competitive programming, and this is me documenting my learnings. So, anything I say is just what I think at the moment and should not be taken as hard truths.
My CP Template
It is always fun to write and maintain your own template file for competitive programming, just like maintaining .virmc
file.
I primarily program in C++. So here is my cpp template file:
#include <bits/stdc++.h> | |
using namespace std; | |
using ll = long long; | |
using vi = vector<int>; | |
using vvi = vector<vector<int>>; | |
using vl = vector<ll>; | |
using vvl = vector<vector<ll>>; | |
using pi = pair<int, int>; | |
using pl = pair<ll, ll>; | |
#define all(x) begin(x), end(x) | |
#define rall(x) rbegin(x), rend(x) | |
#define PB push_back | |
#define MP make_pair | |
#define F first | |
#define S second | |
#define endl '\n' | |
#define forn(i, n) for(ll i = 0; i < n; i++) | |
#define fora(i, a, n) for(ll i = a; i < n; i++) | |
#define readi(e) int e; cin >> e | |
#define readl(e) ll e; cin >> e | |
#define reads(e) string e; cin >> e | |
#define T int tt; cin >> tt; while(tt--) | |
template<typename U> | |
void print(U arr) { | |
for(auto element: arr) { | |
cout << element << " "; | |
} | |
cout << endl; | |
} | |
// read and write into files, rather than standard i/o | |
void setup(string s) { | |
freopen((s+".in").c_str(), "r", stdin); | |
freopen((s+".out").c_str(), "w", stdout); | |
} | |
const int M = 1e9+7; | |
int main(void) { | |
ios::sync_with_stdio(false); | |
cin.tie(0); | |
return 0; | |
} |
Now how to keep improving this template,
- Experiment with different things, and make it customize to your needs.
- Look at other people template and learn.
The same thing could be said for editing your .vimrc
file, that is if you use vim :-)
Top comments (0)