标题
增加 1 行删除 1 行
1一个 OIer 的编译命令 & 缺省源文件1一个 OIer 的编译命令 & 配置文件
正文
增加 105 行删除 67 行
12345678910111213141516171819202122232 行未改动26272829303132333435363710 行未改动48495051525354555657585960616263646566676869707172737475767778798081828384858687883 行未改动92939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271288 行未改动1371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771789 行未改动## 编译命令`-Wno-unused-result` 是为了防止没有使用 `freopen` 的返回值从而产生警告。### (NOI)Linux1. 在 `~/.bashrc` 末尾添加:```bash line-numberscpl () {g++ "./$1.cpp" -o "./$1" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result -Wl,-z,stack-size=1000000000 -fsanitize=undefined,bounds && echo "Compiled ./$1.cpp"}run () {cpl "$1" && echo -e "Running ./$1\n" && time "./$1"}zp() {zip -r "./$1.zip" "./$1" && echo "Compressed folder ./$1"}```2. 可在控制台内运行如下命令以重新加载 `~/.bashrc` 中的命令:2 行未改动```### Windows1. 在(VSCode 中的)Powershell 内运行:```bash line-numberscd C:\Users\{用户名}\Documentsmkdir .\WindowsPowerShellcd .\WindowsPowerShelltype nul > Microsoft.VSCode_profile.ps1type nul > Microsoft.PowerShell_profile.ps110 行未改动$exeFile = ".\$name.exe"if (-not (Test-Path $cppFile)) {Write-Error "Error: $cppFile not found"; return}g++ "$cppFile" -o "$exeFile" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result "-Wl,--stack=1000000000" # 神秘 Windows 没法加 "-fsanitize=undefined,bounds"if ($LASTEXITCODE -eq 0) {Write-Host "Compiled $cppFile" -ForegroundColor Green}}function run {param([string]$name)cpl $nameif ($LASTEXITCODE -eq 0 -and (Test-Path ".\$name.exe")) {Write-Host "Running .\$name.exe" -ForegroundColor CyanWrite-Host "---------------begin---------------" -ForegroundColor Cyan$sw = [System.Diagnostics.Stopwatch]::StartNew()& ".\$name.exe"$sw.Stop()Write-Host "`n----------------end----------------" -ForegroundColor YellowWrite-Host "Time: $($sw.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow}}```3. 可在(VSCode 中的)Powershell 内运行如下命令以重新加载 PowerShell 配置文件:```bash line-numbers. $PROFILE```4. 在部分特殊情况下,可以使用丐版命令来编译运行:```bash line-numbers$name = ".\"; g++ "$name.cpp" -o "$name.exe" -O2 -std=gnu++14 -static -Wall -Wextra -Wshadow -Wno-unused-result "-Wl,--stack=1000000000"; Write-Host "Compiled $name.cpp" -ForegroundColor Green; Write-Host "Running $name.exe" -ForegroundColor Cyan; Write-Host "---------------begin---------------" -ForegroundColor Cyan; $sw = [System.Diagnostics.Stopwatch]::StartNew(); & "$name.exe"; $sw.stop(); Write-Host "`n----------------end----------------" -ForegroundColor Yellow; Write-Host "Time: $($sw.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow```## 缺省源文件### VSCode `cpp.json````json line-numbers3 行未改动"body": ["#include <bits/stdc++.h>","using namespace std;","#define int long long","#define ull unsigned long long","#define pb push_back","#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, llinf = 0x3f3f3f3f3f3f3f3f;","","#if defined(__linux__) || defined(__linux)"," #define gc getchar_unlocked","#elif defined(_WIN32) || defined(_WIN64)"," #define gc _getchar_nolock","#else"," #define gc getchar","#endif","","namespace IO { bool read(int &x) { x=0; char c = gc(); bool f=0; while (!isdigit(c)) { f|=(c=='-');","if (c==EOF) { return 0; } c=gc(); } while(isdigit(c)){ x = (x<<3)+(x<<1)+(c^48); c = gc(); } if (f)","{ x=-x; } return 1; } bool read(string &s) { s=\"\"; char c = gc(); while (!isprint(c) || isspace(c))","{ if (c==EOF) { return 0; } c=gc(); } while(isprint(c) && !isspace(c)){ s+=c; c=gc(); } return 1; }","bool read(char &c) { c = gc(); while(!isprint(c) || isspace(c)) { if(c==EOF){ return 0; } c = gc();","} return 1; } template < typename T , typename ... U > bool read(T &x , U &... y) { if (!read(x)) {","return 0; } return read(y...); } void write(int x) { if(x<0) { putchar('-'); x = -x; } string s=\"\";","do{ s+=x%10^48; x/=10; }while(x); reverse(all(s)); for(char c:s) putchar(c); } void write(char c) {","putchar(c); } void write(const char *s) { while(*s) putchar(*s++); } void write(string x){ for(char","c:x) putchar(c); } template<typename T,typename... U> void write(T x,U... y){ write(x);write(y...);","} template < typename T, typename ... U > void writeln(T x, U... y) { write(x, y...); puts(\"\"); } }","","namespace W_C_B_H {"," using namespace IO;"," void main() {"," }",8 行未改动"description": "C++ 缺省源"}```### Dev-C++```cpp line-numbers#include <bits/stdc++.h>using namespace std;#define int long long#define ull unsigned long long#define pb push_back#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, llinf = 0x3f3f3f3f3f3f3f3f;#if defined(__linux__) || defined(__linux)#define gc getchar_unlocked#elif defined(_WIN32) || defined(_WIN64)#define gc _getchar_nolock#else#define gc getchar#endifnamespace IO { bool read(int &x) { x=0; char c = gc(); bool f=0; while (!isdigit(c)) { f|=(c=='-');if (c==EOF) { return 0; } c=gc(); } while(isdigit(c)){ x = (x<<3)+(x<<1)+(c^48); c = gc(); } if (f){ x=-x; } return 1; } bool read(string &s) { s=""; char c = gc(); while (!isprint(c) || isspace(c)){ if (c==EOF) { return 0; } c=gc(); } while(isprint(c) && !isspace(c)){ s+=c; c=gc(); } return 1; }bool read(char &c) { c = gc(); while(!isprint(c) || isspace(c)) { if(c==EOF){ return 0; } c = gc();} return 1; } template < typename T , typename ... U > bool read(T &x , U &... y) { if (!read(x)) {return 0; } return read(y...); } void write(int x) { if(x<0) { putchar('-'); x = -x; } string s="";do{ s+=x%10^48; x/=10; }while(x); reverse(all(s)); for(char c:s) putchar(c); } void write(char c) {putchar(c); } void write(const char *s) { while(*s) putchar(*s++); } void write(string x){ for(charc:x) putchar(c); } template<typename T,typename... U> void write(T x,U... y){ write(x);write(y...);} template < typename T, typename ... U > void writeln(T x, U... y) { write(x, y...); puts(""); } }namespace W_C_B_H {using namespace IO;void main() {9 行未改动1234567891011121314151617182 行未改动21222324252627282930313210 行未改动4344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889903 行未改动9495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401418 行未改动1501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152169 行未改动## 编译命令### (NOI)Linux1. 在 `~/.bashrc` 末尾添加:```bash line-numberscpl() {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 "Running ./$1\n--------------------------------" && time "./$1"}```2. 可在控制台内运行如下命令以重新加载 `~/.bashrc` 中的命令:2 行未改动```### Windows1. 在(VSCode 中的)Powershell 内运行(用户名不是 `Administrator` 的自行改为实际用户名):```bash line-numberscd C:\Users\Administrator\Documentsmkdir .\WindowsPowerShellcd .\WindowsPowerShelltype nul > Microsoft.VSCode_profile.ps1type nul > Microsoft.PowerShell_profile.ps110 行未改动$exeFile = ".\$name.exe"if (-not (Test-Path $cppFile)) {Write-Error "Error: $cppFile not found"; return}$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"}}function run {param([string]$name)cpl $nameif ($LASTEXITCODE -eq 0 -and (Test-Path ".\$name.exe")) {Write-Host "--------------------------------"$swRun = [System.Diagnostics.Stopwatch]::StartNew()& ".\$name.exe"$swRun.Stop()Write-Host "`n--------------------------------"Write-Host "Run Time: $($swRun.Elapsed.TotalSeconds.ToString('0.000')) s"}}```3. 可在(VSCode 中的)Powershell 内运行如下命令以重新加载 PowerShell 配置文件:```bash line-numbers. $PROFILE```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(); 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" }```## 配置文件### VSCode `cpp.json````json line-numbers3 行未改动"body": ["#include <bits/stdc++.h>","using namespace std;","#define int long long","#define i128 __int128","using ull = unsigned long long;","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); }","","char buf[1 << 20], *p1 = buf, *p2 = buf;","#ifdef LOCAL"," #if defined(__linux__) || defined(__linux)"," #define gc getchar_unlocked"," #elif defined(_WIN32) || defined(_WIN64)"," #define gc _getchar_nolock"," #else"," #define gc getchar"," #endif","#else"," #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)","#endif","","namespace IO { bool read(int &x) { x = 0; char c = gc(); bool f = 0; while (!isdigit(c)) { f |= c == '-';","if (c == EOF) { return 0; } c = gc(); } while (isdigit(c)){ x = (x << 3) + (x << 1) + (c ^ 48); c=gc(); }","if (f) { x=-x; } return 1; } bool read(string &s){ s = \"\"; char c=gc(); while (!isprint(c) || isspace(c))","{ if (c == EOF) { return 0; } c = gc(); } while(isprint(c) && !isspace(c)){ s+=c; c = gc(); } return 1; }","bool read(char &c) { c = gc(); while (!isprint(c) || isspace(c)){ if (c == EOF) { return 0; } c = gc(); }","return 1; } template < typename T, typename U > bool read(pair<T, U> &x) { if (!read(x.fi)) { return 0; }","return read(x.se); } template < typename T, typename ... U > bool read(T & x, U &... y) { if (!read(x)) {","return 0; } return read(y...); } void write(int x) { if(x < 0){ putchar('-'); x = -x; } string s = \"\"; do","{ s += x % 10 ^ 48; x /= 10; } while(x); for (int i = s.size() - 1; ~i; i--) putchar(s[i]); } void write(","char c) { putchar(c); } void write(const char *s) { while(*s) putchar(*s++); } void write(string x) { for","(char c : x) putchar(c); } template <typename T, typename... U> void write(T x, U... y) { write(x); write","(y...); } template <typename T, typename U> void write(pair <T, U> &x) { write(x.fi); putchar(' '); write","(x.se); } template <typename T, typename... U> void writeln(T x, U ... y) { write(x, y...); puts(\"\"); } }","","namespace W_C_B_H {"," using namespace IO;"," void main() {"," }",8 行未改动"description": "C++ 缺省源"}```### VSCode `settings.json````json line-numbers{"C_Cpp.errorSquiggles": "disabled","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 i128 __int128using ull = unsigned long long;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); }char buf[1 << 20], *p1 = buf, *p2 = buf;#ifdef LOCAL#if defined(__linux__) || defined(__linux)#define gc getchar_unlocked#elif defined(_WIN32) || defined(_WIN64)#define gc _getchar_nolock#else#define gc getchar#endif#else#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)#endifnamespace IO { bool read(int &x) { x = 0; char c = gc(); bool f = 0; while (!isdigit(c)) { f |= c == '-';if (c == EOF) { return 0; } c = gc(); } while (isdigit(c)){ x = (x << 3) + (x << 1) + (c ^ 48); c=gc(); }if (f) { x=-x; } return 1; } bool read(string &s){ s = ""; char c=gc(); while (!isprint(c) || isspace(c)){ if (c == EOF) { return 0; } c = gc(); } while(isprint(c) && !isspace(c)){ s+=c; c = gc(); } return 1; }bool read(char &c) { c = gc(); while (!isprint(c) || isspace(c)){ if (c == EOF) { return 0; } c = gc(); }return 1; } template < typename T, typename U > bool read(pair<T, U> &x) { if (!read(x.fi)) { return 0; }return read(x.se); } template < typename T, typename ... U > bool read(T & x, U &... y) { if (!read(x)) {return 0; } return read(y...); } void write(int x) { if(x < 0){ putchar('-'); x = -x; } string s = ""; do{ s += x % 10 ^ 48; x /= 10; } while(x); for (int i = s.size() - 1; ~i; i--) putchar(s[i]); } void write(char c) { putchar(c); } void write(const char *s) { while(*s) putchar(*s++); } void write(string x) { for(char c : x) putchar(c); } template <typename T, typename... U> void write(T x, U... y) { write(x); write(y...); } template <typename T, typename U> void write(pair <T, U> &x) { write(x.fi); putchar(' '); write(x.se); } template <typename T, typename... U> void writeln(T x, U ... y) { write(x, y...); puts(""); } }namespace W_C_B_H {using namespace IO;void main() {9 行未改动