版本比较
一个 OIer 的编译命令 & 配置文件
正文
增加 14 行删除 15 行
43 行未改动4445464748484950517 行未改动59606162646563646566696768697071727374753 行未改动798081828483848586876 行未改动9495969799100101102989910410010110210310410510610710810911059 行未改动17017117217317517617717817417518017617717817918018118218318418518639 行未改动43 行未改动 if (-not (Test-Path $cppFile)) { Write-Error "Error: $cppFile not found"; return } Write-Host "Compiling $cppFile" $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" 7 行未改动function run { param([string]$name) cpl $name if ($LASTEXITCODE -eq 0 -and (Test-Path ".\$name.exe")) { Write-Host "Running .\$name.exe" Write-Host "---------------begin---------------" Write-Host "--------------------------------" $swRun = [System.Diagnostics.Stopwatch]::StartNew() & ".\$name.exe" $swRun.Stop() Write-Host "`n----------------end----------------" 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 = ".\"; $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(); 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"$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 eb emplace_back", "#define fi first", "#define se second", "#define all(a) (a).begin(), (a).end()", "#define i128 __int128", "using ull = unsigned long long;", "using i128 = __int128;", "using ld = long double;", "using pii = pair<int, int>;", "using p3i = pair<int, pii>;", "#define eb emplace_back", "#define fi first", "#define se second", "#define all(a) (a).begin(), (a).end()", "const int inf = 0x3f3f3f3f, Inf = 0x3f3f3f3f3f3f3f3f;", "template<typename T, typename U> void chkmin(T &x, U y) { x > y && (x = y); }", "template<typename T, typename U> void chkmax(T &x, U y) { x < y && (x = y); }", "",59 行未改动```cpp line-numbers#include <bits/stdc++.h>using namespace std;#define int long long#define eb emplace_back#define fi first#define se second#define all(a) (a).begin(), (a).end()#define i128 __int128using ull = unsigned long long;using i128 = __int128;using ld = long double;using pii = pair<int, int>;using p3i = pair<int, pii>;#define eb emplace_back#define fi first#define se second#define all(a) (a).begin(), (a).end()const int inf = 0x3f3f3f3f, Inf = 0x3f3f3f3f3f3f3f3f;template<typename T, typename U> void chkmin(T &x, U y) { x > y && (x = y); }template<typename T, typename U> void chkmax(T &x, U y) { x < y && (x = y); }
39 行未改动