Debug
inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);
Read In
template<typename Type>
inline void read(Type &res)
{
res = 0;
int ch = getchar(), flag = 0;
while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }
Base Template
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);
typedef long long LL;
typedef pair<int, int> PII;
const int N = 200010;
const int INF = 0x3f3f3f3f;
template<typename Type>
inline void read(Type &res)
{
res = 0;
int ch = getchar(), flag = 0;
while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }
signed main()
{
return 0;
}
GCC Optimize
#pragma GCC target("avx") // AVX指令集(不懂的去问度娘)
#pragma GCC optimize(1) // o1优化
#pragma GCC optimize(2) // o2优化
#pragma GCC optimize(3) // o3优化
#pragma GCC optimize("Ofast") // ofast优化(优化到破坏标准合规性的点),
#pragma GCC optimize("inline") // inline中和
#pragma GCC optimize("-fgcse") // fgcse优化
#pragma GCC optimize("-fgcse-lm") //-fgcse-lm
#pragma GCC optimize("-fipa-sra") //除换
#pragma GCC optimize("-ftree-pre") //快速tree
#pragma GCC optimize("-ftree-vrp") //去重tree
#pragma GCC optimize("-fpeephole2") // flatco2优化
#pragma GCC optimize("-ffast-math") //数论优化
#pragma GCC optimize("-fsched-spec") //富硒优化
#pragma GCC optimize("unroll-loops") //图论plus优化
#pragma GCC optimize("-falign-jumps") //极优化
#pragma GCC optimize("-falign-loops") //图论重+排除
#pragma GCC optimize("-falign-labels") // lamb优化
#pragma GCC optimize("-fdevirtualize") // fugechar优化
#pragma GCC optimize("-fcaller-saves") //负优化排除
#pragma GCC optimize("-fcrossjumping") //极优化p+
#pragma GCC optimize("-fthread-jumps") //多重极优化
#pragma GCC optimize("-funroll-loops") //消除分支可以减少预测的可能性能:比如小的循环可以展开比如循环次数小于64次(可以使用GCC选项 //-funroll-loops)
#pragma GCC optimize("-fwhole-program") //弗洛伊德优化
#pragma GCC optimize("-freorder-blocks") //半刻优化
#pragma GCC optimize("-fschedule-insns") // fschedule-insns优化
#pragma GCC optimize("inline-functions") // inline-functions优化
#pragma GCC optimize("-ftree-tail-merge") //-ftree-tail-merge优化
#pragma GCC optimize("-fschedule-insns2") //-fschedule-insns2优化
#pragma GCC optimize("-fstrict-aliasing") //-fstrict-aliasing优化
#pragma GCC optimize("-fstrict-overflow") //不知道
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
update on 2024.10.25.
标签:GCC,res,缺省,pragma,inline,优化,optimize,模板 From: https://www.cnblogs.com/ThySecret/p/18523432