Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a5180e4

Browse files
adds a better template
1 parent ea34654 commit a5180e4

File tree

1 file changed

+60
-38
lines changed

1 file changed

+60
-38
lines changed

‎scripts/setupCpp.sh

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ if [ -f "$name" ]; then
1212
echo "File already exists!"
1313
else
1414
cat <<EOL > "$name"
15-
#include<bits/stdc++.h>
16-
15+
#include <bits/stdc++.h>
1716
using namespace std;
1817
1918
// Type definitions
2019
typedef long long ll;
21-
typedef long double ld;
2220
typedef pair<int, int> pii;
2321
typedef pair<ll, ll> pll;
2422
typedef vector<int> vi;
@@ -28,81 +26,105 @@ typedef vector<pll> vpll;
2826
typedef vector<vi> vvi;
2927
typedef vector<vl> vvl;
3028
31-
//Macros
32-
#define nline "\\n"
29+
//Macros
30+
#define nline "\n"
3331
#define all(x) (x).begin(), (x).end()
3432
#define rall(x) (x).rbegin(), (x).rend()
3533
#define sz(x) (int)(x).size()
3634
#define pb push_back
3735
#define mp make_pair
3836
#define F first
3937
#define S second
40-
#define forn(i, n) for(int i = 0; i < int(n); i++)
41-
#define forr(i, a, b) for(int i = a; i <= b; i++)
42-
#define ford(i, a, b) for(int i = a; i >= b; i--)
43-
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
38+
#define forn(i, n) for (int i = 0; i < int(n); i++)
39+
#define forr(i, a, b) for (int i = a; i <= b; i++)
40+
#define ford(i, a, b) for (int i = a; i >= b; i--)
41+
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
42+
43+
// clang-format off
44+
// Debug macros
45+
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
46+
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
47+
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
48+
49+
// Debug template functions
50+
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
51+
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
52+
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
53+
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
54+
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
55+
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
56+
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
57+
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
58+
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
59+
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
60+
// clang-format on
4461
4562
// Constants
4663
const int MOD = 1e9 + 7;
4764
const ll INF = 1e18;
4865
const double EPS = 1e-9;
4966
const double PI = acos(-1);
5067
68+
// Utility functions
5169
ll mod_add(ll a, ll b, ll m = MOD) { return ((a % m) + (b % m)) % m; }
5270
ll mod_sub(ll a, ll b, ll m = MOD) { return ((a % m) - (b % m) + m) % m; }
5371
ll mod_mul(ll a, ll b, ll m = MOD) { return ((a % m) * (b % m)) % m; }
54-
55-
ll mod_pow(ll base, ll exp, ll m = MOD) {
72+
ll mod_pow(ll base, ll exp, ll m = MOD)
73+
{
5674
ll res = 1;
5775
base %= m;
58-
while (exp > 0) {
59-
if (exp & 1) res = mod_mul(res, base, m);
76+
while (exp > 0)
77+
{
78+
if (exp & 1)
79+
res = mod_mul(res, base, m);
6080
base = mod_mul(base, base, m);
6181
exp >>= 1;
6282
}
6383
return res;
6484
}
65-
66-
ll mod_inv(ll a, ll m = MOD) {
67-
return mod_pow(a, m - 2, m); // Only works if m is prime
85+
ll mod_inv(ll a, ll m = MOD)
86+
{
87+
return mod_pow(a, m - 2, m); // Only works if m is prime
6888
}
69-
70-
ll mod_div(ll a, ll b, ll m = MOD) {
89+
ll mod_div(ll a, ll b, ll m = MOD)
90+
{
7191
return mod_mul(a, mod_inv(b, m), m);
7292
}
7393
74-
// Binary exponentiation (for non-modular calculations)
75-
ll binpow(ll base, ll exp) {
94+
ll binpow(ll base, ll exp, ll mod = MOD)
95+
{
7696
ll res = 1;
77-
while (exp > 0) {
78-
if (exp & 1) res *= base;
79-
base *= base;
97+
base %= mod;
98+
while (exp > 0)
99+
{
100+
if (exp & 1)
101+
res = (res * base) % mod;
102+
base = (base * base) % mod;
80103
exp >>= 1;
81104
}
82105
return res;
83106
}
84-
85-
void solve(){
86-
107+
/************/
108+
void solve()
109+
{
110+
// Your solution code here
87111
}
88112
89-
int main(){
90-
113+
int main()
114+
{
91115
ios_base::sync_with_stdio(0);
92116
cin.tie(0);
93117
cout.tie(0);
94-
95-
#ifndef ONLINE_JUDGE
96-
freopen("./outputs/input.txt", "r", stdin);
97-
freopen("./outputs/output.txt", "w", stdout);
98-
#endif
99-
100-
// int t; cin>>t;while(t--)
101-
// solve();
102-
118+
#ifndef ONLINE_JUDGE
119+
freopen("./outputs/input.txt", "r", stdin);
120+
freopen("./outputs/output.txt", "w", stdout);
121+
#endif
122+
int t;
123+
cin >> t;
124+
while (t--)
125+
solve();
103126
return 0;
104127
}
105-
106128
// Explanation
107129
/*
108130

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /