VSCode settings.json

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
{
//* window
"window.commandCenter": false,
//* explorer
"explorer.confirmDragAndDrop": false,
"explorer.confirmPasteNative": false,
//* workbench
// "workbench.editor.enablePreview": false,
"workbench.tree.indent": 12,
"workbench.startupEditor": "none",
"workbench.list.smoothScrolling": true,
"workbench.layoutControl.enabled": false,
"workbench.iconTheme": "material-icon-theme",
"workbench.editor.empty.hint": "hidden",
"workbench.colorTheme": "Catppuccin Mocha",
//* extensions
"extensions.closeExtensionDetailsOnViewChange": true,
//* editor
"editor.fontSize": 15.5,
"editor.inlayHints.enabled": "on",
"editor.wordWrap": "on",
"editor.occurrencesHighlight": "singleFile",
// "editor.acceptSuggestionOnEnter": "off",
"editor.hover.delay": 100,
"editor.mouseWheelZoom": true,
"editor.smoothScrolling": true,
"editor.cursorBlinking": "smooth",
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.minimap.enabled": false,
// "editor.minimap.autohide": true,
"editor.guides.bracketPairs": "active",
"editor.cursorSmoothCaretAnimation": "on",
"editor.snippetSuggestions": "top",
"editor.suggestSelection": "recentlyUsed",
"editor.fontLigatures": true,
"editor.wordBasedSuggestions": "currentDocument",
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true,
"editor.linkedEditing": true,
//* files
"files.autoSaveDelay": 100,
"files.autoSave": "afterDelay",
"files.associations": {
".clangd": "yaml",
".clang-format": "yaml",
"out": "plaintext"
},
//* Python
"python.terminal.focusAfterLaunch": true,
"python.analysis.autoFormatStrings": true,
"python.analysis.completeFunctionParens": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.languageServer": "Pylance",
"python.analysis.autoIndent": true,
"python.REPL.enableREPLSmartSend": false,
"python.analysis.typeCheckingMode": "basic",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
}
},
//* C/C++
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
//* debug
"debug.allowBreakpointsEverywhere": true,
"debug.console.closeOnEnd": true,
"debug.showBreakpointsInOverviewRuler": true,
"debug.terminal.clearBeforeReusing": true,
//* terminal
"terminal.integrated.fontFamily": "CommitMono Nerd Font",
// "terminal.integrated.fontFamily": "Maple Mono SC NF",
"terminal.integrated.enableMultiLinePasteWarning": "never",
// "terminal.integrated.defaultProfile.windows": "Arch (WSL)",
"terminal.integrated.defaultProfile.linux": "fish",
"terminal.integrated.smoothScrolling": true,
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.fontSize": 15,
//* extensions
"extensions.autoCheckUpdates": false,
"extensions.ignoreRecommendations": true,
"extensions.autoUpdate": false,
//* better-comments
"better-comments.tags": [
{
"tag": "!",
"color": "#FF2D00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "?",
"color": "#3498DB",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "~",
"color": "#474747",
"strikethrough": true,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "todo",
"color": "#FF8C00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "*",
"color": "#98C379",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
}
],
//* scm
"scm.diffDecorations": "overview",
//* markdown
"markdown.extension.completion.enabled": true,
//* git
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.openRepositoryInParentFolders": "never"
}

Win clear.bat

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
@echo off
setlocal enabledelayedexpansion

REM 设置文件夹路径数组,使用分号分隔不同的路径
set "folders=.cph; build"
for %%i in (%folders%) do (
if exist "%%i\" (
pushd "%%i"
del /q *
popd
echo Dir %%i has been cleared.
) else (
echo Dir %%i does not exist.
)
)

REM 删除当前目录下的所有 .cpp 文件
set "fileType=*.cpp"
if exist "%fileType%" (
del /f /q %fileType%
)
echo Files .cpp has been cleared.

REM 删除当前目录下的所有 .py 文件
set "fileType=*.py"
if exist "%fileType%" (
del /f /q %fileType%
)
echo Files .py has been cleared.

REM 删除当前目录下的所有 .exe 文件
set "fileType=*.exe"
if exist "%fileType%" (
del /f /q %fileType%
)
echo Files .exe has been cleared.

endlocal

工作区 settings.json

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
{
"cph.general.saveLocation": "D:/Code/OJ_Code/.cph",
// "cph.general.menuChoices": "cpp python",
"cph.general.defaultLanguage": "cpp",
"cph.language.cpp.Args": "-std=c++23 -O2 -ID:/Code/OJ_Code/headers -DLOCAL",
/* 注意 cph 采用 clang++ 编译 */
// "cph.language.cpp.Args": "-std=c++23 -O2 -stdlib=libc++ -ID:/Code/OJ_Code/headers -DLOCAL",
"cph.language.python.Command": "pypy3.10",
"cph.general.firstTime": false,
"cph.general.autoShowJudge": true,
// "cph.general.useShortCodeForcesName": true,
"clangd.arguments": [
"--log=verbose",
"--pretty",
"--all-scopes-completion",
"--header-insertion=never",
"--background-index", // 后台自动分析文件
"--completion-style=detailed",
// "--completion-style=bundled", // 打包(重载函数只给出一个建议)
"--pch-storage=memory",
// "--compile-commands-dir=${workspaceFolder}/build",
// "--compile-commands-dir=build",
"--function-arg-placeholders=false"
],
"clangd.fallbackFlags": [
"-std=c++23",
"-O2",
"-pipe",
"-Wno-vla", // 禁用变量长度数组(VLA)的警告
"-g",
"-DLOCAL",
"-ID:/Code/OJ_Code/headers"
// CompilationDatabase: build/
]
}

工作区 C++ 开发 tasks.json

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
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C++",
"command": "clang++",
// "command": "g++", // 注意调试功能
"args": [
"-std=c++23",
// "-fsanitize=undefined", // win 开不了
// "-O2",
// "-pipe",
// "-Wno-vla", // 禁用变量长度数组(VLA)的警告
// "-fdiagnostics-color=always",
//
/* 使用 println() */
// "-stdlib=libc++",
// "-fexperimental-library",
//// 加入 libc++ 的 include 和 lib 路径
// "-isystem",
// "D:/SDK/MSYS2/mingw64/include/c++/v1",
// "-L",
// "D:/SDK/MSYS2/mingw64/lib",
// "-lc++",
// "-lc++abi",
//
"-g",
"-DLOCAL",
"-ID:/Code/OJ_Code/headers",
// "-Wconversion",
// "-Wall",
"${file}",
"-o",
"${workspaceFolder}/build/${fileBasenameNoExtension}.exe"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

工作区 launch.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/build/${fileBasenameNoExtension}.exe",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C++",
"internalConsoleOptions": "neverOpen",
"console": "integratedTerminal"
}
]
}

clang-format 配置

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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
---
BasedOnStyle: Google # Microsoft # LLVM # Google

# 对齐
AccessModifierOffset: -4 # 访问修改器偏移量
AlignAfterOpenBracket: Align # AlwaysBreak # DontAlign # BlockIndent # Align
AlignArrayOfStructures: Left

AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false

AlignEscapedNewlines: Left # LeftWithLastLine
AlignOperands: Align # DontAlign # Align
AlignTrailingComments:
Kind: Never
OverEmptyLines: 0

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true

AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: true

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes

AttributeMacros:
- __capability

BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: After

BraceWrapping:
# !没有以下子项:
# AfterMapLiteral: true
#
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach # Custom # Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true

ColumnLimit: 200
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE

# include
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: "^<.*"
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ".*"
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: "([-_](test|unittest))?$"
IncludeIsMainSourceRegex: ""

# indent
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None # 插入末尾逗号

IntegerLiteralSeparator:
Binary: 4
BinaryMinDigits: 7
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0

JavaScriptQuotes: Leave
JavaScriptWrapImports: true

KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1

NamespaceIndentation: All

ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true

PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200

PPIndentWidth: -2
PointerAlignment: Left
QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- "c++"
- "C++"
CanonicalDelimiter: ""
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google

ReferenceAlignment: Pointer

ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave

ShortNamespaceLines: 1

## sort
SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric

# space
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false

SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1

SpacesInParentheses: false
SpacesInSquareBrackets: false

Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION

TabWidth: 8
UseTab: Never

WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE

clangd 配置

1
2
3
4
5
6
7
8
9
10
11
CompileFlags:
Add:
- -std=c++26
- -O2
- -pipe
- -Wno-vla # 禁用变量长度数组(VLA)的警告
- -g
- -DLOCAL
- -ID:/Code/OJ_Code/headers

# CompilationDatabase: build/

VSCode 清理配置缓存

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
@REM example:
@REM del "%userprofile%/AppData/Local/Microsoft/vscode-cpptools/ipch/" /s /q /f
@REM rd "%userprofile%/AppData/Local/Microsoft/vscode-cpptools/ipch/" /s /q
@REM md "%userprofile%/AppData/Local/Microsoft/vscode-cpptools/ipch/"

@echo off

call:EmptyOneDir "%userprofile%\AppData\Local\Microsoft\vscode-cpptools\ipch"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\CachedExtensionVSIXs"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\Cache"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\CachedData"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\CachedExtensions"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\CachedExtensionVSIXs"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\Code Cache"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\Crashpad"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\logs"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\Service Worker\CacheStorage"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\Service Worker\ScriptCache"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\User\workspaceStorage"
call:EmptyOneDir "%userprofile%\AppData\Roaming\Code\User\History"

goto end

:EmptyOneDir rem same as Let empty [path] /q
echo empty %1
echo del %1 /s /q /f
del %1 /s /q /f
echo rd %1 /s /q
rd %1 /s /q
echo md %1
md %1
:end

LeetCode 辅助头文件

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
#include <vector>

struct ListNode {
int val;
ListNode* next;

ListNode() : val(-1), next(nullptr) {}
ListNode(int val) : val(val), next(nullptr) {}
ListNode(int val, ListNode* next) : val(val), next(next) {}
};

struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;

TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};

class Node {
public:
int val;
std::vector<Node*> children;

Node() {}
Node(int _val) { val = _val; }
Node(int _val, std::vector<Node*> _children) {
val = _val;
children = _children;
}
};

using namespace std;

Python 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
[tool.black]
line-length = 120

[tool.isort]
line_length = 120

skip = ["tests", "setup.py"]
skip_glob = ["*.pyc", "__pycache__"]

force_to_top = ["pkg_resources"]

quiet = true
order_by_type = true

代码片段 snippets

cpp

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
{
"LeetCode": {
"scope": "cpp",
"prefix": "sol",
"body": [
"#include <bits/stdc++.h>",
"#ifdef LOCAL",
"#include \"LeetCode.hpp\"",
"#include \"debug.h\"",
"#else",
"#define debug(...) void(0)",
"#endif",
"using i64 = long long;",
"",
"$0",
"",
"#ifdef LOCAL",
"int main() {",
" //",
"}",
"#endif"
]
},
"acm": {
"scope": "cpp",
"prefix": "acm",
"body": [
"#include <bits/stdc++.h>",
"",
"#ifdef LOCAL",
"#include \"debug.h\"",
"#endif",
"",
"using namespace std;",
"using i64 = long long;",
"",
"void solve() {",
" $0",
"}",
"",
"int main() {",
" ios::sync_with_stdio(false);",
" cin.tie(nullptr);",
"",
" solve();",
"",
" return 0;",
"}"
]
},
"acms": {
"scope": "cpp",
"prefix": "acms",
"body": [
"#include <bits/stdc++.h>",
"",
"#ifdef LOCAL",
"#include \"debug.h\"",
"#endif",
"",
"using namespace std;",
"using i64 = long long;",
"",
"void solve() {",
" $0",
"}",
"",
"int main() {",
" ios::sync_with_stdio(false);",
" cin.tie(nullptr);",
"",
" int T;",
" cin >> T;",
" while (T--) {",
" solve();",
" }",
"",
" return 0;",
"}"
]
},
"MOD_1'000'000'007": {
"scope": "cpp",
"prefix": "MOD_1'000'000'007",
"body": "static constexpr int MOD = 1'000'000'007;"
},
"MOD_9998244353": {
"scope": "cpp",
"prefix": "MOD_998244353",
"body": "static constexpr int MOD = 998244353;"
},
"inf": {
"scope": "cpp",
"prefix": "inf",
"body": "static constexpr $1 inf = $0;"
},
"readFromFile": {
"scope": "cpp",
"prefix": "freopen",
"body": ["#ifdef LOCAL", " // freopen(\"in.txt\", \"r\", stdin);", " // freopen(\"out.txt\", \"w\", stdout);", "#endif"]
},
"UDLR": {
"scope": "cpp",
"prefix": "UDLR",
"body": [
"void go(int& x, int& y, char ch) {",
" if (ch == 'U') {",
" x--;",
" } else if (ch == 'D') {",
" x++;",
" } else if (ch == 'L') {",
" y--;",
" } else if (ch == 'R') {",
" y++;",
" }",
"}"
]
},
"二分查找": {
"scope": "cpp",
"prefix": "binary_search",
"body": [
"auto check = [&](auto x) {",
" $0",
" return true;",
"};",
"",
"int lo = 0, hi = 1E9;",
"while (lo + 1 < hi) {",
" auto mid = lo + (hi - lo) / 2;",
"",
" if (check(mid)) {",
"",
" } else {",
" ",
" }",
"}"
]
},
"上下左右": {
"scope": "cpp",
"prefix": "dir",
"body": ["static constexpr int dx[] = {1, 0, -1, 0};", "static constexpr int dy[] = {0, 1, 0, -1};"]
},
"马": {
"scope": "cpp",
"prefix": "dir_horse",
"body": ["static constexpr int dx[] = {1, 1, 2, 2, -1, -1, -2, -2};", "static constexpr int dy[] = {2, -2, 1, -1, 2, -2, 1, -1};"]
},
"周围": {
"scope": "cpp",
"prefix": "dir_around",
"body": ["static constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};", "static constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};"]
},
"四角": {
"scope": "cpp",
"prefix": "dir_corner",
"body": ["static constexpr int dx[] = {-1, -1, 1, 1};", "static constexpr int dy[] = {1, -1, -1, 1};"]
},
"init": {
"scope": "cpp",
"prefix": "init",
"body": ["auto init = [] {", " $0", " return 0;", "}();"]
},
"initWithVal": {
"scope": "cpp",
"prefix": "initWithVal",
"body": ["auto $1 = [&] {", " $0", "}();"]
},
"lambda": {
"scope": "cpp",
"prefix": "lambda",
"body": ["auto $1 = [&]($0) {", " ", "};", "$1();"]
},
"lambda递归": {
"scope": "cpp",
"prefix": "lambda_rec",
"body": ["auto $1 = [&](auto&& $1, $0) {", " ", "};", "$1($1);"]
},
"lambda递归23版": {
"scope": "cpp",
"prefix": "lambda23_rec",
"body": ["auto $1 = [&](this auto&& $1, $0) {", " ", "};", "$1();"]
},
"prefix": {
"scope": "cpp",
"prefix": "prefix",
"body": ["vector<i64> pre(n + 1);", "for (int i = 0; i < n; i++) {", " pre[i + 1] = pre[i] + a[i];", "}"]
},
"suffix": {
"scope": "cpp",
"prefix": "suffix",
"body": ["vector<i64> suf(n + 1);", "for (int i = n - 1; i >= 0; i--) {", " suf[i] = suf[i + 1] + a[i];", "}"]
},
"随机数生成": {
"scope": "cpp",
"prefix": "random",
"body": [
"mt19937_64 gen(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());",
"uniform_int_distribution<int> disInt(8e8, 9e8);",
"uniform_real_distribution<int> disReal(8e8, 9e8);",
"auto rnd = disInt(gen); // 固定值"
]
},
"下标排序": {
"scope": "cpp",
"prefix": "order",
"body": ["vector<int> ord($1);", "iota(ord.begin(), ord.end(), 0);", "sort(ord.begin(), ord.end(), [&](int i, int j)-> bool { return $0 ;});"]
}
// "priority_queue": {
// "scope": "cpp",
// "prefix": "priority_queue",
// "body": [
// "#include <ext/pb_ds/priority_queue.hpp>",
// "",
// "__gnu_pbds::priority_queue<$1, ${2:less<>}, __gnu_pbds::pairing_heap_tag> pq;"
// ]
// },
}

python

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
{
"LeetCode": {
"scope": "python",
"prefix": "sol",
"body": [
"import random",
"from bisect import bisect_left, bisect_right",
"from collections import Counter, defaultdict, deque",
"from functools import cache, lru_cache, reduce",
"from heapq import heapify, heappop, heappush, heappushpop, nlargest, nsmallest",
"from itertools import accumulate, combinations, groupby, pairwise, permutations, product",
"from math import gcd, hypot, isqrt, lcm, sqrt",
"from operator import add, iand, ior, mul, xor",
"from string import ascii_letters, ascii_lowercase, ascii_uppercase",
"from timeit import timeit",
"from typing import List, NamedTuple, Optional, Tuple, cast",
"",
"# from pkg_resources import working_set",
"from more_itertools import distinct_combinations, distinct_permutations, distribute, divide, factor, intersperse, is_sorted, locate, longest_common_prefix, minmax, nth_combination, nth_permutation, partition, sieve, sliding_window, substrings, substrings_indexes, totient",
"from sortedcontainers import sorteddict as SD",
"from sortedcontainers import sortedlist as SL",
"from sortedcontainers import sortedset as SS",
"",
"fmax = lambda x, y: x if x >= y else y",
"fmin = lambda x, y: y if x >= y else x",
"",
"# https://github.com/GopherTeen/template",
""
]
},
"acm": {
"scope": "python",
"prefix": "acm",
"body": [
"import sys",
"",
"input = lambda: sys.stdin.readline().strip()",
"",
"I = lambda: input()",
"II = lambda: int(input())",
"FI = lambda: float(input())",
"LI = lambda: input().split()",
"LII = lambda: list(map(int, input().split()))",
"LFI = lambda: list(map(float, input().split()))",
"LGI = lambda: list(map(lambda x: int(x) - 1, input().split()))",
"",
"fmax = lambda x, y: x if x >= y else y",
"fmin = lambda x, y: y if x >= y else x",
"",
"# https://github.com/GopherTeen/template",
"",
"def solve():",
" $0",
" pass",
"",
"",
"if __name__ == \"__main__\":",
" solve()",
""
]
},
"acms": {
"scope": "python",
"prefix": "acms",
"body": [
"import sys",
"",
"input = lambda: sys.stdin.readline().strip()",
"",
"I = lambda: input()",
"II = lambda: int(input())",
"FI = lambda: float(input())",
"LI = lambda: input().split()",
"LII = lambda: list(map(int, input().split()))",
"LFI = lambda: list(map(float, input().split()))",
"LGI = lambda: list(map(lambda x: int(x) - 1, input().split()))",
"",
"fmax = lambda x, y: x if x >= y else y",
"fmin = lambda x, y: y if x >= y else x",
"",
"# https://github.com/GopherTeen/template",
"",
"def solve():",
" $0",
" pass",
"",
"",
"if __name__ == \"__main__\":",
" for _ in range(II()):",
" solve()",
""
]
},
"MOD_1'000'000'007": {
"scope": "python",
"prefix": "MOD_1'000'000'007",
"body": "MOD = 1_000_000_007"
},
"MOD_9998244353": {
"scope": "python",
"prefix": "MOD_998244353",
"body": "MOD = 998244353"
},
"二分查找": {
"scope": "python",
"prefix": "binary_search",
"body": [
"def check(x: int) -> bool:",
" $0",
" return True",
"",
"",
"lo, hi = 0, 10**9",
"while lo + 1 < hi:",
" mid = lo + (hi - lo) // 2",
"",
" if check(mid):",
" lo = mid",
" else:",
" hi = mid",
""
]
},
"上下左右": {
"scope": "python",
"prefix": "dir",
"body": ["dx = [1, 0, -1, 0]", "dy = [0, 1, 0, -1]"]
},
"马": {
"scope": "python",
"prefix": "dir_horse",
"body": ["dx = [1, 1, 2, 2, -1, -1, -2, -2]", "dy = [2, -2, 1, -1, 2, -2, 1, -1]"]
},
"周围": {
"scope": "python",
"prefix": "dir_around",
"body": ["dx = [1, 0, -1, 0, 1, 1, -1, -1]", "dy = [0, 1, 0, -1, 1, -1, 1, -1]"]
},
"四角": {
"scope": "python",
"prefix": "dir_corner",
"body": ["dx = [-1, -1, 1, 1]", "dy = [1, -1, -1, 1]"]
}
}

go

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
{
"acm": {
"prefix": "acm",
"scope": "go",
"body": [
"package main",
"",
"import (",
" \"bufio\"",
" \"os\"",
")",
"",
"var (",
" in = bufio.NewReader(os.Stdin)",
" out = bufio.NewWriter(os.Stdout)",
"",
" // MOD = 1_000_000_007",
" // MOD = 998244353",
")",
"",
"func solve() {",
" $0",
"}",
"",
"func main() {",
" defer out.Flush()",
"",
" solve()",
"}",
""
]
},
"acms": {
"prefix": "acms",
"scope": "go",
"body": [
"package main",
"",
"import (",
" \"bufio\"",
" \"fmt\"",
" \"os\"",
")",
"",
"var (",
" in = bufio.NewReader(os.Stdin)",
" out = bufio.NewWriter(os.Stdout)",
"",
" // MOD = 1_000_000_007",
" // MOD = 998244353",
")",
"",
"func solve() {",
" $0",
"}",
"",
"func main() {",
" defer out.Flush()",
"",
" var T int",
" fmt.Fscan(in, &T)",
"",
" for range T {",
" solve()",
" }",
"}"
]
},
"in": {
"prefix": "Fscan",
"scope": "go",
"body": "fmt.Fscan(in, &$0)"
},
"out-f": {
"prefix": "Fprintf",
"scope": "go",
"body": "fmt.Fprintf(out, \"$0\")"
},
"out-ln": {
"prefix": "Fprintln",
"scope": "go",
"body": "fmt.Fprintln(out, $0)"
},
"order": {
"prefix": "order",
"scope": "go",
"body": ["ord := make([]int, $1)", "for i := range ord {", " ord[i] = i", "}", "sort.Slice(ord, func(i, j int) bool {", " i, j = ord[i], ord[j]", " return $0", "})"]
}
}