随笔分类 - 图论
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int n, m; 7 const int maxn = 200005; 8 int fa[maxn]; 9 int sum[maxn]; 10 11 int Find(int x){ 12 if (x == fa[x]) 13 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int n, m; 9 int f[510]; 10 11 struct node 12 { 13 int...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 const int maxn = 10005; 6 int n, m; 7 int fa[28]; 8 struct node 9 { 10 int x, y; 11 int cost; 12 }arr[maxn]; 13 14 void init() 15 {...
阅读全文
摘要:1 //我看过Discuss说不能用克鲁斯卡尔因为有很多边 2 //但是只能用G++过,C++的确超时 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct node 9 { 10 int a, b, cost; 11 }c[30000]; 12 int fa[505];...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 10005 8 int fa[MAXN]; 9 struct node 10 { 11 int from, to, len; 12 }arr[MAXN]; 13 14 bool cmp(no...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 100005; 7 const int L = 100; 8 const int R = 100000; 9 int t, n, m, ans; 10 double total; 11 struct n...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #define N 110 5 #define M 5000 6 using namespace std; 7 8 int n, m, u[M], v[M], w[M], r[M], p[N]; 9 bool cmp(int i, int j){ return w[i]> m >> n&&m) 15 ...
阅读全文
摘要:1 //克鲁斯卡尔 2 #include 3 #include 4 using namespace std; 5 const int maxn = 10005; 6 struct node 7 { 8 int begin, end, len; 9 }cun[maxn]; 10 int n, fa[maxn], ans, m; 11 12 bool cmp(node a...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 1005 8 int n, m; 9 int fa[MAXN]; //父节点 10 int mark[MAXN]; 11 12 void init() 13 { 14 for (int ...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 int G[300][300]; 5 int Prev[300]; //路径上每个节点的前驱节点 6 bool Visited[300]; 7 int n,m; //m是顶点数目,顶点编号从1开始 1是源,m是汇, n是 边数 8 9 int Augment() 10 { ...
阅读全文
摘要:1 //克鲁斯卡尔(最小生成树) 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 100005; 8 int n, t; 9 struct node 10 { 11 int bagin, end, len; 12 }arr[maxn]; 13 int fa[max...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 100005 8 int fa[MAXN]; //父节点 9 int vis[MAXN]; 10 int Min = 0xffffff; 11 int Max = 0; 12 13 v...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 500 8 int map[MAXN][MAXN]; 9 int mark[MAXN]; 10 int pipei[MAXN]; 11 int n; 12 13 int search(int a) 1...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 150 8 int n; //十字路口的数量 9 int m; //路的个数 10 int map[MAXN][MAXN]; 11 int x[MAXN], y[MAXN]; 12 int ...
阅读全文
摘要:1 #include 2 #include 3 4 int f[1001], g[1001]; 5 6 int find(int x) //并查集的查找,找到共同的父亲 7 { 8 if (f[x] != x) 9 f[x] = find(f[x]); 10 return f[x]; 11 } 12 13 in...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int M = 100005; 8 int a, b; 9 int father[M]; //记录父节点 10 bool circle; //判断是否存在环 11 bool visit...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 #define MAXN 5000 9 int fa[MAXN]; //父节点 10 int Rank[MAXN]; //数的高度 11 int ans; 12 13 void init(i...
阅读全文