-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippet.json
More file actions
252 lines (252 loc) · 7.51 KB
/
snippet.json
File metadata and controls
252 lines (252 loc) · 7.51 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
{
"自适应快读": {
"scope": "cpp",
"prefix": "@read",
"body": [
"template<typename T>",
"void read(T&ans)",
"{",
" ans=0;",
" char us=getchar();",
" bool f=false;",
" while(us<48||us>57){",
" f|=(us==45);",
" us=getchar();",
" }",
" while(us>47&&us<58){",
" ans=(ans<<1)+(ans<<3)+(us^48);",
" us=getchar();",
" }",
" ans*=f?-1:1;",
" return;",
"}",
"template<typename T,typename ...O>",
"void read(T&x,O&...oth)",
"{",
" read(x);",
" read(oth...);",
"}",
"template<typename T=signed int>T read(void){T x;read(x);return x;}",
],
"description": "fast_read",
"isFileTemplate": false
},
"链表双端队列": {
"scope": "cpp",
"prefix": "@deque_list",
"body": [
"template <class T>",
"struct deque",
"{",
" struct node",
" {",
" node *lst;",
" node *nt;",
" T data;",
" node(node *a, node *b, T c) : lst(a), nt(b), data(c) {}",
" };",
" node *fst;",
" node *lst;",
" deque()",
" {",
" lst = fst = new node(nullptr, nullptr, 0);",
" }",
" void push_back(T x)",
" {",
" node *us = new node(lst, nullptr, x);",
" lst = lst->nt = us;",
" }",
" void push_front(T x)",
" {",
" node *us = new node(fst, fst->nt, x);",
" fst->nt = fst->nt->lst = us;",
" }",
" void pop_front()",
" {",
" if (fst->nt)",
" {",
" fst = fst->nt;",
" delete fst->lst;",
" lst->lst=nullptr;",
" }",
" }",
" void pop_back()",
" {",
" if (lst->lst)",
" {",
" lst = lst->lst;",
" delete lst->nt;",
" lst->nt=nullptr;",
" }",
" }",
" T front()",
" {",
" return fst->nt->data;",
" }",
" T back()",
" {",
" return lst->data;",
" }",
" bool empty()",
" {",
" return lst == fst;",
" }",
"};",
],
"description": "deque_list",
"isFileTemplate": false
},
"随机访问双端队列": {
"scope": "cpp",
"prefix": "@deque_random",
"body": [
"template <class T, unsigned int sz>",
"struct deque",
"{",
" T data[sz];",
" int fst, lst;",
" deque(void) { fst = 1, lst = 0; }",
" void push_back(T x){data[++lst]=x;}",
" void push_front(T x){data[--fst]=x;}",
" void pop_front(){++fst;}",
" void pop_back(){--lst;}",
" T front(){return data[fst];}",
" T back(){return data[lst];}",
" bool empty(){return fst>lst;}",
"};",
],
"description": "deque_random",
"isFileTemplate": false
},
"对拍构造": {
"scope": "cpp",
"prefix": "@build",
"body": [
"#include <iostream>",
"#include <cstdio>",
"using namespace std;",
"int main()",
"{",
" int n;",
" freopen(\"seed.txt\", \"r\", stdin);",
" cin >> n;",
" srand(n);",
" fclose(stdin);",
" freopen(\"seed.txt\", \"w\", stdout);",
" cout << rand();",
"}",
],
"description": "debug",
"isFileTemplate": true
},
"min和max的宏定义": {
"scope": "cpp",
"prefix": "@mm",
"body": [
"#define mi2(a,b) (a<b?a:b)",
"#define mx2(a,b) (a>b?a:b)"
],
"description": "A define of min and max",
"isFileTemplate": false
},
"分块宏定义": {
"scope": "cpp",
"prefix": "@fk",
"body": [
"#define belong(x) ((x-1)/sqrtn+1)",
"#define begin(x) ((x-1)*sqrtn+1)",
"#define end(x) ((x)*sqrtn)"
],
"description": "divide in blocks",
"isFileTemplate": false
},
"邻接表基础存图": {
"scope": "cpp",
"prefix": "@fst",
"body": [
"$1 fst[MAXN],nt[MAXM];",
"$2 to[MAXM];",
"$3 v[MAXM];",
"void addline($2 a,$2 b,$3 c=1){",
" static int i=0;",
" to[++i]=b,nt[i]=fst[a],fst[a]=i,v[i]=c;",
" to[++i]=a,nt[i]=fst[b],fst[b]=i,v[i]=c;",
"}",
]
},
"初始化数组": {
"scope": "cpp",
"prefix": "@mem",
"body": [
"memset($1,$2,sizeof $1);",
]
},
"初始化指针": {
"scope": "cpp",
"prefix": "@mem",
"body": [
"memset($1,$2,$3*sizeof *$1);",
]
},
"邻接表遍历单点边": {
"scope": "cpp",
"prefix": "@for",
"body": [
"for($1=fst[$2];$1;$1=nt[$1])",
]
},
"流读写": {
"scope": "cpp",
"prefix": "@io",
"body": [
"namespace IO{",
" int len=0;",
" char ibuf[(1<<20)+1],*iS,*iT,out[(1<<26)+1];",
" #define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<20)+1,stdin),(iS==iT?EOF:*iS++):*iS++)",
" #define reg register",
" inline int read(){",
" reg char ch=gh();",
" reg int x=0;",
" reg char t=0;",
" while(ch<'0'||ch>'9') t|=ch=='-',ch=gh();",
" while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();",
" return t?-x:x;",
" }",
" inline void putc(char ch){",
" out[len++]=ch;",
" }",
" template<class T>",
" inline void write(T x){",
" if(x<0)putc('-'),x=-x;",
" if(x>9)write(x/10);",
" out[len++]=x%10+48;",
" }",
" inline void flush(){",
" fwrite(out,1,len,stdout);",
" len=0;",
" }",
"}",
"using IO::read;",
"using IO::write;",
"using IO::flush;",
"using IO::putc;",
]
},
"重链剖分定义": {
"scope": "cpp",
"prefix": "@zpld",
"body": [
"$1 zpld[MAXN],bigc[MAXN],depth[MAXN],fa[MAXN],dfsn[MAXN];",
"$2 weight[MAXN];",
"$3 data[MAXN];",
]
},
"必备头文件": {
"prefix": "@include",
"scope": "cpp",
"body": [
"#include<iostream>",
"#include<cstdio>",
],
},
}