-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvscodesnippets.json
More file actions
51 lines (51 loc) · 1.03 KB
/
vscodesnippets.json
File metadata and controls
51 lines (51 loc) · 1.03 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
{
"cptemplate": {
"prefix": ["cp"],
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"void solve() {",
" $0",
"}",
"",
"int main() {",
" int ntc;",
" scanf(\"%d\", &ntc);",
" for (int itc = 1; itc <= ntc; ++itc) {",
" printf(\"Case #%d: \", itc);",
" solve();",
" }",
"}"
],
"description": "CP Template"
},
"BIT": {
"prefix": ["BIT"],
"body": [
"template<typename T> class BIT {",
"public:",
" BIT(int n): v(vector<T>(n+1)), n(n) {}",
" T sum(int k) {",
" T s = 0;",
" for (int i = k; i > 0; i -= (i & -i)) {",
" s += this->v[i];",
" }",
" return s;",
" }",
" T sum(int l, int r) {",
" return this->sum(r) - this->sum(l-1);",
" }",
" void update(int k, T v) {",
" for (int i = k; i <= this->n; i += (i & -i)) {",
" this->v[i] += v;",
" }",
" }",
"private:",
" vector<T> v;",
" int n;",
"};"
],
"description": "BIT (Binary Indexed Tree) / Fenwick Tree"
}
}