摘要:
K #include <iostream> #include <cstdio> #include <vector> using namespace std; const int N = 2000010; int n, m, head[N], ver[N << 1], nex[N << 1], tot 阅读全文
摘要:
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-8; const doub 阅读全文
摘要:
题目链接 #include <iostream> #include <cstdio> #include <set> using namespace std; const int N = 100010; int t, n, m, a[N], ans[N]; struct P { int l, r, v 阅读全文
摘要:
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #define clr(f, n) memset(f, 0, sizeof(int) * (n)) #def 阅读全文
摘要:
题目链接 #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; const int N = 1000010, Q = 1000010; int n, q, le 阅读全文
摘要:
#include <iostream> #include <cstdio> using namespace std; const int N = 1000010, hashBase[2] = {29, 31}, hashMod[2] = {1000000007, 1000000009}, hashN 阅读全文
摘要:
邻接矩阵 设一个图中有个点,那么这个图的邻接矩阵就是一个的矩阵。 所以用一个二维数组来储存这个邻接矩阵。 举个例子:若已知无向图中,到的路径权值是,那可以给赋值为,由于这是一个无向图,所以还需要反向连一次边,就是把$ 阅读全文
摘要:
线性筛约数个数 #include <iostream> #include <cstdio> using namespace std; const int N = 10000000; int n, prime[N + 1], dnum[N + 1]; void init (int n) { dnum[ 阅读全文
摘要:
Kruskal算法 给定一张无向图,若用这张图的全部节点构成一棵树,且这棵树所有边的权值之和最小,则称这棵树为最小生成树。 所以很显然我们只需找出条边,让这些边使这张图不构成环的前提下,边权尽可能小,这就是Kruskal算法。 算法流程:我们把边权按照从小到大排序,然后按顺序把他们接到 阅读全文
摘要:
深度优先搜索(DFS) 深度优先搜索的思想是从一个节点出发,不停地向深处访问它的子节点,直到它的子节点除了它的父亲外没有别的节点与之相连,那么这时就回溯,退到它的父亲节点,继续上一步的操作。 所以,深度优先搜索是一个递归的过程。 理解了深度优先搜索的思想,现在来看看它的代码是如何实现的: void 阅读全文