-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnippets.json
More file actions
188 lines (188 loc) · 4.35 KB
/
Snippets.json
File metadata and controls
188 lines (188 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
{
"cpp snippets": {
"prefix": "boiler",
"body": [
"#include<iostream>",
"using namespace std;",
"int main()",
"{",
" return 0;",
"}"
],
"description": "to produce the main snippet for cpp"
},
"Competitive Snippet": {
"prefix": "cpBoiler",
"body": [
"#include<bits/stdc++.h>",
"using namespace std;",
"#define ll long long",
"int main()",
"{",
" ios_base::sync_with_stdio(false);",
" #ifndef ONLINE_JUDGE",
" freopen(\"./.vscode/input.txt\", \"r\", stdin);",
" freopen(\"./.vscode/output.txt\", \"w\", stdout);",
" #endif",
" cin.tie(NULL);",
" cout.tie(NULL);",
"",
" $0",
" return 0;",
"}"
],
"description": "to produce the main snippet for competitive programming"
},
"Competitive Snippet with test cases": {
"prefix": "cpBoilerTest",
"body": [
"#include<bits/stdc++.h>",
"",
"using namespace std;",
"#define ll long long",
"",
"int main()",
"{",
" ios_base::sync_with_stdio(false);",
" cin.tie(NULL);",
" cout.tie(NULL);",
" int t;",
" cin >> t;",
" while ( t-- ){",
" $0",
" }",
" return 0;",
"}"
],
"description": "to produce the main snippet for competitive programming with test cases"
},
"Competitive Boiler Plate Code": {
"prefix": "cpBoilerPlate",
"body": [
"#include <bits/stdc++.h>",
"",
"#define ll long long",
"#define int long long",
"#define For(i, a, b) for(int i = (a);i < (b);i++)",
"#define in(a) for(auto& it:(a)) cin>>it;",
"#define out(b) for(auto& it:(b)) cout<<it<<\" \";",
"#define vi vector<int>",
"#define vl vector<long long>",
"#define pb push_back",
"#define F first",
"#define S second",
"#define ld long double",
"#define pii pair<int,int>",
"",
"const ll MOD = 1e9+7;",
"int n;",
"",
"using namespace std;",
"",
"void wise_crack()",
"{",
" //Solution for given problem.",
" $0",
" return ;",
"}",
"signed main()",
"{",
" //Coder --> binary_Rahul",
" //College --> NIT Raipur",
" ios_base::sync_with_stdio(false);",
" cin.tie(NULL);",
" cout.tie(NULL);",
" //For T number of test cases.",
" int t=1;",
" cin>>t;",
" while(t--){",
" wise_crack();",
" }",
" return 0;",
"}"
]
},
"Dijkstra": {
"prefix": "Dijkstra",
"body": [
"vector<int> Dijkstra(int V,vector<vector<int>> adj[],int s) {",
" priority_queue<pair<int,int> ,vector<pair<int,int>>, greater<pair<int,int>>> pq;",
" vector<int> dist(V,1e9);",
" dist[s] = 0;",
" pq.push({0,s});",
" while (!pq.empty()) {",
" auto [dis,node] = pq.top();",
" pq.pop();",
" for(auto &it:adj[node]) {",
" int edgeWt = it[1];",
" int adjNode = it[0];",
" if(dis + edgeWt < dist[adjNode]) {",
" dist[adjNode] = dis + edgeWt;",
" pq.push({dist[adjNode],adjNode});",
" }",
" }",
" }",
" return dist;",
"}"
]
},
"BinarySearch": {
"prefix": "BinarySearch",
"body": [
"int isPresent(int x, vector<int> &a)",
"{",
" int l = 0, h = a.size() - 1, mid;",
" while (l <= h)",
" {",
" mid = l + (h - l)/2;",
" if ( a[mid]==x) return mid;",
" else if ( x > a[mid] ) l = mid + 1;",
" else h = mid - 1;",
" }",
" return -1;",
"}"
]
},
"DFS": {
"prefix": "dfs",
"body": [
"void dfs (int node, vector<int> adj[], vector<int>& vis,vector<int>& dfsTrav ) {",
" vis[node] = 1;",
" dfsTrav.push_back(node);",
" for(auto& it:adj[node]) {",
" if(!vis[it]) ",
" dfs(it,adj,vis,dfsTrav);",
" }",
"}"
]
},
"String_Hash": {
"prefix": "get_Hash",
"body": [
"long long get_hash (string s ) ",
"{",
"long long h = 0;",
"for (char c : s)",
" h = (h * 31 + (c - 'a' + 1)) % MOD;",
"return h;",
"}"
]
},
"Mod_Exp": {
"prefix": "Mod_Expo",
"body": [
"ll mod_exp(ll base, ll exp, ll mod)",
"{",
" ll res = 1;",
" while (exp > 0)",
" {",
" if (exp % 2 == 1)",
" res = (res * base) % mod;",
" base = (base * base) % mod;",
" exp /= 2;",
" }",
" return res;",
"}"
]
}
}