powerful competitive programming workspace template

This commit is contained in:
xkm
2026-04-14 00:24:53 +08:00
parent b281762f0e
commit 48e23609d4
8 changed files with 131 additions and 0 deletions

11
.clang-format Normal file
View File

@@ -0,0 +1,11 @@
BasedOnStyle: Google
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: true
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
FixNamespaceComments: false

11
.clangd Normal file
View File

@@ -0,0 +1,11 @@
CompileFlags:
Add:
- -DLOCAL
- -D_GLIBCXX_DEBUG
- -std=c++23
- -Wall
- -Wextra
- -Werror=uninitialized
- -Werror=return-type
- -Wno-unused-const-variable
- -Wno-sign-compare

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
/gmon.out
/out.txt
/in.txt
/tmp/

1
.pch.cpp Normal file
View File

@@ -0,0 +1 @@
#include <bits/stdc++.h>

30
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/tmp/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": false
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": false
}
],
"preLaunchTask": "C/C++: make"
}
]
}

17
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: make",
"command": "make",
"args": [
"SRC=${fileBasename}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}

33
Makefile Normal file
View File

@@ -0,0 +1,33 @@
CXX := clang++
CXXFLAGS := -fdiagnostics-color=always -g \
-Wall -Wextra \
-Werror=uninitialized \
-Werror=return-type \
-Wno-sign-compare \
-Wno-unused-const-variable \
-fsanitize=undefined \
-D_GLIBCXX_DEBUG \
-pg \
-DLOCAL \
-std=c++23 \
-pipe
SRC ?= template.cpp
TARGET := tmp/$(basename $(notdir $(SRC)))
PCH := tmp/precompiled.pch
PCH_HEADER := .pch.cpp
all: $(TARGET)
$(TARGET): $(SRC) $(PCH) | tmp
$(CXX) $(CXXFLAGS) -include-pch $(PCH) $(SRC) -o $(TARGET)
tmp:
mkdir -p tmp
$(PCH): $(PCH_HEADER) | tmp
$(CXX) $(CXXFLAGS) -x c++-header $(PCH_HEADER) -o $(PCH)
clean:
rm -rf tmp

24
template.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int64 inf = 0x3f3f3f3f;
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int Mod = 1e9 + 7;
const int N = 3e5 + 10;
void solve() {
cout << "Hello world" << '\n';
}
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}