版本比较
一个 OIer 的编译命令 & 配置文件
正文
增加 19 行删除 20 行
5 行未改动67891010111213131415161726 行未改动44454647484849505152535456555657585960616264656364656669706768697071727374753 行未改动798081828483848586876 行未改动9495969799981019910010110210310310410510410510610747 行未改动15515615715816115916016116216316416516616716816917017117217317417417617517617717817917817918018018118218342 行未改动5 行未改动
```bash line-numbers
cpl() { g++ "./$1.cpp" -o "./$1" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result -Wno-sign-compare -Wl,-z,stack-size=1000000000 -fsanitize=undefined,bounds -DLOCAL && echo -e "\e[32mCompiled ./$1.cpp\e[0m" g++ "./$1.cpp" -o "./$1" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result -Wno-sign-compare -Wl,-z,stack-size=1000000000 -fsanitize=undefined,bounds -DLOCAL && echo "Compiled ./$1.cpp"}run() { cpl "$1" && echo -e "\e[36mRunning ./$1\n---------------begin---------------\e[0m" && local TIMEFORMAT=$'\e[33m\n----------------end----------------\nTime: %3Rs\e[0m' && time "./$1" cpl "$1" && echo -e "Running ./$1\n--------------------------------" && time "./$1"}```
2. 可在控制台内运行如下命令以重新加载 `~/.bashrc` 中的命令:26 行未改动 if (-not (Test-Path $cppFile)) { Write-Error "Error: $cppFile not found"; return } Write-Host "Compiling $cppFile" -ForegroundColor Green $swCompile = [System.Diagnostics.Stopwatch]::StartNew() g++ "$cppFile" -o "$exeFile" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result -Wno-sign-compare "-Wl,--stack=1000000000" -DLOCAL # 神秘 Windows 没法加 "-fsanitize=undefined,bounds" $swCompile.Stop() if ($LASTEXITCODE -eq 0) { Write-Host "Compile Time: $($swCompile.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow Write-Host "Compile Time: $($swCompile.Elapsed.TotalSeconds.ToString('0.000')) s" }}
function run { param([string]$name) cpl $name if ($LASTEXITCODE -eq 0 -and (Test-Path ".\$name.exe")) { Write-Host "Running .\$name.exe" -ForegroundColor Green Write-Host "---------------begin---------------" -ForegroundColor Cyan Write-Host "--------------------------------" $swRun = [System.Diagnostics.Stopwatch]::StartNew() & ".\$name.exe" $swRun.Stop() Write-Host "`n----------------end----------------" -ForegroundColor Yellow Write-Host "Run Time: $($swRun.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow Write-Host "`n--------------------------------" Write-Host "Run Time: $($swRun.Elapsed.TotalSeconds.ToString('0.000')) s" }}
```
3. 可在(VSCode 中的)Powershell 内运行如下命令以重新加载 PowerShell 配置文件:
3 行未改动
4. 在部分特殊情况下,可以使用丐版命令来编译运行(将 `$name` 的值替换为程序实际路径并去掉 `.cpp` 即可):
```bash line-numbers$name = ".\"; Write-Host "Compiling $name.cpp" -ForegroundColor Green; $swCompile = [System.Diagnostics.Stopwatch]::StartNew(); g++ "$name.cpp" -o "$name.exe" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result "-Wl,--stack=1000000000" -DLOCAL; $swCompile.Stop(); Write-Host "Compile Time: $($swCompile.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow; Write-Host "Running $name.exe" -ForegroundColor Green; Write-Host "---------------begin---------------" -ForegroundColor Cyan; $swRun = [System.Diagnostics.Stopwatch]::StartNew(); & "$name.exe"; $swRun.Stop(); Write-Host "`n----------------end----------------" -ForegroundColor Yellow; Write-Host "Run Time: $($swRun.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow$name = ".\"; $swCompile = [System.Diagnostics.Stopwatch]::StartNew(); g++ "$name.cpp" -o "$name.exe" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result -Wno-sign-compare "-Wl,--stack=1000000000" -DLOCAL; $swCompile.Stop(); if ($LASTEXITCODE -eq 0) { echo "Compile Time: $($swCompile.Elapsed.TotalSeconds.ToString('0.000')) s" ; echo --------------------------------; $swRun = [System.Diagnostics.Stopwatch]::StartNew(); & "$name.exe"; $swRun.Stop(); echo `n--------------------------------; echo "Run Time: $($swRun.Elapsed.TotalSeconds.ToString('0.000')) s" }```
## 配置文件
6 行未改动 "body": [ "#include <bits/stdc++.h>", "using namespace std;", "#define int long long", "#define ull unsigned long long", "#define i128 __int128", "#define ld long double", "using ull = unsigned long long;", "using ld = long double;", "using pii = pair<int, int>;", "using p3i = pair<int, pii>;", "#define eb emplace_back", "#define mt make_tuple", "#define pii pair<int, int>", "#define p3i pair<int, pii>", "#define fi first", "#define se second", "#define all(a) (a).begin(), (a).end()", "const int inf = 0x3f3f3f3f, Inf = 0x3f3f3f3f3f3f3f3f;",47 行未改动
```json line-numbers{ "C_Cpp.errorSquiggles": "disabled", "files.autoSave": "onWindowChange", "files.autoSave": "onFocusChange", "editor.fontSize": 16, "editor.renderWhitespace": "boundary", "editor.wordWrap": "on" "workbench.colorTheme": "Quiet Light", "editor.trimAutoWhitespace": false}```
### Dev-C++ 缺省源
```cpp line-numbers#include <bits/stdc++.h>using namespace std;#define int long long#define ull unsigned long long#define i128 __int128#define ld long doubleusing ull = unsigned long long;using ld = long double;using pii = pair<int, int>;using p3i = pair<int, pii>;#define eb emplace_back#define mt make_tuple#define pii pair<int, int>#define p3i pair<int, pii>#define fi first#define se second#define all(a) (a).begin(), (a).end()const int inf = 0x3f3f3f3f, Inf = 0x3f3f3f3f3f3f3f3f;42 行未改动