
ACM_图论
chudongfang2015
开心开心!!!!!!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
图的最短路径算法分析与总结
图的求最短路径算法大类可以分为4种,在这里一一介绍 1.Floy算法 2.Dijkstra算法 3.Bellman-Ford算法 4.Bellman-Ford算法的队列优化 一, Floy算法 基本思想: 1.数据结构:邻接矩阵 2.算法思想:动态规划 核心代码: for(k=1;k<=n;k++) { for(i=1;i<=n;原创 2016-04-13 15:30:39 · 1995 阅读 · 0 评论 -
Connections Gym - 101630C DFS/有向图的强联通分量边集
题目链接求有向图强连通分量的2n个边的边集 首先从1开始DFS可以走到的所有点,并记录走过的边 这样就满足了从1可达所有其他点 然后从1开始DFS走反向边,这样保证其他点可达1点. 两遍dfs #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5+5; struct原创 2017-12-12 22:07:10 · 405 阅读 · 0 评论 -
[CCPC杭州] Bomb 强连通分量
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1894 Accepted Submission(s): 631 Problem Description There are N bombs ne原创 2017-10-16 01:21:42 · 346 阅读 · 0 评论 -
[图论紫书/Ch5] Ideal Path UVA - 1599 BFS/正向反向BFS
题目链接先从终点BFS到起点,并记录下其到终点的距离,然后从起点BFS到终点,并优先选取边权值小的.#include<bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9+10; const int maxn = 100005;struct node { int to; int co原创 2017-10-18 15:48:10 · 349 阅读 · 0 评论 -
[紫书/Ch6] Play on Words 欧拉回路判定
Play on Words Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8780 Accepted Submission(s): 3015 Problem Description Some of the原创 2017-10-17 23:23:18 · 316 阅读 · 0 评论 -
二分图的最大匹配
二分图指的是这样一种图,其所有顶点可以分成两个集合X和Y,其中X或Y中任意两个在同一集合中的点都不相连,所有的边关联在两个顶点中,恰好一个属于集合X,另一个属于集合Y。给定一个二分图G,M为G边集的一个子集,如果M满足当中的任意两条边都不依附于同一个顶点,则称M是一个匹配。图中包含边数最多的匹配称为图的最大匹配。 二分图的最大匹配有两种求法,第一种是最大流;第二种就是我现在要讲的匈牙利转载 2017-09-09 22:31:24 · 431 阅读 · 0 评论 -
[图论:选边满足各点度的奇偶] CF 840B
B. Leha and another game about graphtime limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Leha plays a computer game, where is on each level is g原创 2017-08-19 09:45:40 · 1089 阅读 · 2 评论 -
HDU 4565矩阵快速幂—— So Easy!
题目链接借鉴别人的一张解题思路 转化成了 (a^n + b^n) %M#include<iostream> #include<string> #include<vector> #include<algorithm> #include<queue> #include<cstdio> #include<cstring> #include<cmath> #include<map> using names原创 2017-08-09 22:05:02 · 398 阅读 · 0 评论 -
POJ 3159 Candies(差分规划+SPFA)
During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the原创 2017-04-29 23:08:10 · 358 阅读 · 0 评论 -
Codeforces Round #394 (Div. 2) 题解
Codeforces Round #394 (Div. 2) 题解A. Dasha and Stairs解题思路:判断一下两者相减的绝度值是否为小于2。注意特判两个0的情况时间复杂度:O(1) 空间复杂度:O(1)代码如下:#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <alg原创 2017-02-01 17:02:43 · 460 阅读 · 0 评论 -
A - 搜索I 简单图论
A - 搜索I Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1181 Description 呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而原创 2016-11-26 08:36:20 · 419 阅读 · 0 评论 -
最小生成树--Kruskal算法
与Prim算法不同,Kruskal算法基于并查集和贪心算法,利用并查集判断其是否存在循环。 Kruskal算法基本思想: 对所有边进行排序,优先选取权重小的边,并同时判断其是否联通(利用并查集判断) 数据结构:数组 算法思想:快排,贪心,递归原创 2016-04-19 17:22:56 · 374 阅读 · 0 评论 -
最小生成树--prim算法
最小生成树---prim算法 基本思想: 任选一个节点为头节点,然后找出离”整个树‘距离最小的节点,纳入树内,直到所有节点都纳入树内。 数据结构: 数组,邻接矩阵储存图 算法思想:基于贪心算法:即每一步都选择当前最优路径。 关键:离“整个树”最小: 利用dis[]数组储存 来看代码: for(k=1;k<=n;k++)//更新di原创 2016-04-18 19:43:54 · 420 阅读 · 0 评论 -
并查集分析
并查集:不相交集数据结构 #include #include void init(); int getf(int v); void merge(int v,int u); int f[1000],n,m,k,sum; int main() { int i,x,y; scanf("%d %d",&n,&m); init(); for(i=1;i<=m;i++) {原创 2016-04-17 20:11:57 · 343 阅读 · 0 评论 -
Graph Reconstruction ZOJ - 3732 Havel-Hakimi定理 + 构造
Graph ReconstructionLet there be a simple graph with N vertices but we just know the degree of each vertex. Is it possible to reconstruct the graph only by these information?A simple graph is an undire原创 2017-12-14 18:49:55 · 401 阅读 · 0 评论