随笔分类 -  模板

摘要:#include <bits/stdc++.h> using namespace std; struct toposort { vector<vector<int>> e; vector<int> tp , din; int n ; toposort() {} toposort(int n) { t 阅读全文
posted @ 2023-12-12 23:09 Ke_scholar 阅读(34) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2023-12-12 02:08 Ke_scholar 阅读(30) 评论(0) 推荐(0)
摘要: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); 阅读全文
posted @ 2023-12-09 23:44 Ke_scholar 阅读(28) 评论(0) 推荐(0)
摘要:已通过洛谷模板:(【矩阵快速幂】、【行列式计算】) 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)) 阅读全文
posted @ 2023-12-05 15:20 Ke_scholar 阅读(41) 评论(2) 推荐(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 阅读全文
posted @ 2023-12-04 12:51 Ke_scholar 阅读(68) 评论(0) 推荐(0)
摘要:二分图最大匹配模板(匈牙利算法) P3386 【模板】二分图最大匹配 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) struct augment_path { vector<vector<int> > g; vector<int> pa; // 匹配 vector<int> pb 阅读全文
posted @ 2023-12-02 12:32 Ke_scholar 阅读(55) 评论(0) 推荐(0)
摘要:struct EulerSieve { private: int n; vector<int> phi; // 欧拉函数数组 vector<int> mu; // 莫比乌斯函数数组 vector<int> nextp; // 最小质因子数组 vector<int> prime; // 素数列表 ve 阅读全文
posted @ 2023-11-30 17:48 Ke_scholar 阅读(45) 评论(2) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; template <typename T> class SparseTable { using VT = vector<T>; using VVT = vector<VT>; using func_type 阅读全文
posted @ 2023-11-26 01:51 Ke_scholar 阅读(53) 评论(0) 推荐(0)
摘要://快速幂 //底数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; 阅读全文
posted @ 2023-10-31 19:28 Ke_scholar 阅读(29) 评论(0) 推荐(0)
摘要:欧拉定理求质因数: //欧拉定理求质因数 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 阅读全文
posted @ 2023-10-31 19:26 Ke_scholar 阅读(37) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2023-10-31 19:26 Ke_scholar 阅读(46) 评论(0) 推荐(0)