193 words
1 minutes
Competitive Programming Template (C++)
🧰 Competitive Programming Template (C++)
This is my go-to C++ template for solving competitive programming problems efficiently. It includes standard type aliases, fast I/O, vector helpers, and a solve()
driver.
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>#define vll vector<long long>#define vvi vector<vector<int>>#define vvll vector<vector<long long>>
// Read / Write Utilitiestemplate <class T>void read(T &t) { cin >> t; }
template <class T>void print(T &t) { cout << t << " "; }
template <class T>void println(T &t) { cout << t << "\n"; }
template <class V, class N>void read_v(V &v, N n) { v.resize(n); for (auto &x : v) read(x);}
template <class T>void print_v(T &t) { for (auto x : t) { print(x); }}
// Type Aliases#if __cplusplus >= 201103L#include <cstdint>typedef int32_t i32;typedef uint32_t ui32;typedef int64_t i64;typedef uint64_t ui64;#elsetypedef long i32;typedef unsigned long ui32;typedef long long i64;typedef unsigned long long ui64;#endif
// Main and Drivervoid solve();
int main(void) { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
solve(); return 0;}
void solve() { // Code here}
Competitive Programming Template (C++)
https://uxharshit.github.io/posts/cp-template/