随笔分类 - 模板
摘要:#include <bits/stdc++.h> using namespace std; struct toposort { vector<vector<int>> e; vector<int> tp , din; int n ; toposort() {} toposort(int n) { t
阅读全文
摘要:include <bits/stdc++.h> using namespace std; struct LCA { int n; vector<int> dep; vector<vector<int>> e; vector<array<int, 21>> fa; LCA() {} LCA(int n
阅读全文
摘要:struct DIJ { using i64 = long long; using PII = pair<i64, i64>; vector<i64> dis; vector<vector<PII>> G; DIJ() {} DIJ(int n) { dis.assign(n + 1, 1e18);
阅读全文
摘要:已通过洛谷模板:(【矩阵快速幂】、【行列式计算】) template<class T> struct Matrix { i64 N; vector<vector<T>> A; Matrix() : N(0) {} Matrix(int n) : N(n), A(n, vector<T>(n, 0))
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; struct trie { int n; vector<array<int, 26>> trans; vector<int> cnt; trie() : n(0) { new_node(); } int ne
阅读全文
摘要:二分图最大匹配模板(匈牙利算法) P3386 【模板】二分图最大匹配 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) struct augment_path { vector<vector<int> > g; vector<int> pa; // 匹配 vector<int> pb
阅读全文
摘要:struct EulerSieve { private: int n; vector<int> phi; // 欧拉函数数组 vector<int> mu; // 莫比乌斯函数数组 vector<int> nextp; // 最小质因子数组 vector<int> prime; // 素数列表 ve
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; template <typename T> class SparseTable { using VT = vector<T>; using VVT = vector<VT>; using func_type
阅读全文
摘要://快速幂 //底数128 long long ksm(__int128 a, long long b, long long p) { __int128 res = 1; while (b) { if (b & 1)res = res * a % p; b >>= 1; a = a * a % p;
阅读全文
摘要:欧拉定理求质因数: //欧拉定理求质因数 long long phi(long long x) { long long i; long long res = x; for (i = 2; i * i <= x; i++) { if (x % i == 0) { res = res / i * (i
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; struct UFS { int sz; vector<int> rank, p; void link(int x, int y) { if (x == y) return; if (rank[x] > ra
阅读全文

浙公网安备 33010602011771号