随笔分类 - 模板
摘要:洛谷模板测试七倍经验: https://www.luogu.com.cn/record/238785118 https://www.luogu.com.cn/record/238783283 https://www.luogu.com.cn/record/238788990 https://www.
阅读全文
摘要:template<class Info, class Tag> struct LazySegmentTree { int n; std::vector<Info> info; std::vector<Tag> tag; LazySegmentTree() : n(0) {} LazySegmentT
阅读全文
摘要:mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
阅读全文
摘要://无向图 int idx = 0; bool found = false; vector<int> loop,dfn(n + 1, 0), fa(n + 1, 0); function<void(int)> dfs = [&](int u) { dfn[u] = ++idx; for (int v
阅读全文
摘要:constexpr int N = 3001; vector<bitset<N>> a(N); //n个方程,m个未知数,p组常数项 vector<vector<bool>> guass(int n, int m, int p) { int rank = 0; vector<int> pivot_c
阅读全文
摘要:【牛客一道模板】 struct MidNum { multiset<int> p, q; //p 从大到小 q从小到大 void work() { while (p.size() > q.size() + 1) { q.insert(*p.rbegin()); p.erase(--p.end());
阅读全文
摘要:洛谷模板题已过【P2617 Dynamic Rankings】 /* 动态持久化线段树(树状数组套线段树)模板类 * 用于解决带修改的区间第k小和区间排名查询问题 * 核心功能: * - 单点更新 O(log n log V) * - 区间第k小查询 O(log n log V) * - 区间排名查
阅读全文
摘要:需要C++20及以上,从Jiangly那偷得(bushi using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; using i128 =
阅读全文
摘要:auto getMin = [](vector<int> &v)->vector<int> { int n = v.size(); int k = 0, i = 0, j = 1; while (k < n && i < n && j < n) { if (v[(i + k) % n] == v[(
阅读全文
摘要:洛谷模板题AC通过 #include <bits/stdc++.h> using namespace std; using i64 = long long; int P; template<class Node> struct SegmentTree { #define lc u<<1 #defin
阅读全文
摘要:将佬[1]$的值域分块封装了一下,洛谷过了 template <typename T> struct Block { int B, N, tot; vector<T> cnt, Cnt, L, R, belong; Block(int n): N(n - 1), B(sqrt(n - 1)), cn
阅读全文
摘要:struct DSU { vector<int> fa, sz, st; DSU(int n) { fa.resize(n); sz.assign(n, 1); iota(fa.begin(), fa.end(), 0); } int find(int x) { return fa[x] == x
阅读全文
摘要:自适应辛普森法 double a, b, c, d, l, r; const double eps = 1e-8; double F(double x) { //需要积分的公式 return (c * x + d) / (a * x + b); } double simpson(double l,
阅读全文
摘要:简单封装了一下浮点加法乘法,未验证 struct BigFloat { static const int N = 100, n = 16; //位数,保留位数 vector<int> integer;//整数部分(逆序存储)123. -->321. vector<int> decimal;//小数部
阅读全文
摘要:复杂度 \(O(n^\frac 23)\),计算 \(1\sim n\) 的素数个数 #define div(a, b) (1.0 * (a) / (b)) #define half(x) (((x) - 1) / 2) i64 Meissel_Lehmer(i64 n) { if (n <= 3)
阅读全文
摘要:using i128 = __int128; istream &operator>>(istream &is, i128 &x) { string s; is >> s; bool neg = false; x = 0; for (char c : s) { if (c == '-') neg =
阅读全文
摘要:template<class Node> struct PersidentSegmentTree { #define lc(u) tr[u].l #define rc(u) tr[u].r const int n; int tot = 0; vector<Node> tr; vector<int>
阅读全文
摘要:jiangly的(偷一下 i64 mul(i64 a, i64 b, i64 m) { return static_cast<__int128>(a) * b % m; } i64 power(i64 a, i64 b, i64 m) { i64 res = 1 % m; for (; b; b >
阅读全文
摘要:已通过洛谷【模板1】、【模板2区间第k小】、 【区间小于x的个数-牛客】、【区间小于x的个数-代码源 杭电4417怀疑数据可能有问题(?,调了一下午没调出来,如有大佬改出来了麻烦告知下错哪了qwq /* 可持久化线段树(主席树)模板 * @tparam Node: 节点结构体类型,需包含左右子节点和
阅读全文
摘要:template<class Info> struct SegmentTree { int n; std::vector<Info> info; SegmentTree() : n(0) {} SegmentTree(int n_, Info v_ = Info()) { init(n_, v_);
阅读全文

浙公网安备 33010602011771号