随笔分类 -  图论

摘要:题目描述 在有向图G 中,每条边的长度均为1 ,现给定起点和终点,请你在图中找一条从起点到终点的路径,该路径满足以下条件: 1 .路径上的所有点的出边所指向的点都直接或间接与终点连通。 2 .在满足条件1 的情况下使路径最短。 注意:图G 中可能存在重边和自环,题目保证终点没有出边。 请你输出符合条 阅读全文
posted @ 2016-11-02 22:05 pandaB 阅读(530) 评论(0) 推荐(0)
摘要:有负环也资磁√ #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #define inf 233333333333 using namespace std; int cost[1000][1000];/ 阅读全文
posted @ 2016-10-21 15:51 pandaB 阅读(140) 评论(0) 推荐(0)
摘要:QAQ不资磁负环的最短路算法 模板酱 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #define inf 233333333333 using namespace std; struct edge 阅读全文
posted @ 2016-10-21 14:35 pandaB 阅读(111) 评论(0) 推荐(0)
摘要:模板题 https://www.luogu.org/problem/show?pid=3366 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<qu 阅读全文
posted @ 2016-09-27 18:11 pandaB 阅读(164) 评论(0) 推荐(0)
摘要://spfa算的是从x到其他所有点的最短路 QAQ是一种求单源最短路的算法,判断负环非常资磁 用到的变量: n:点的个数从1到n标号 /* queue<int>q :一个队列,用stl或者手打,priority_queue也很资磁啊 head:队列头 tail:队列尾 bool vis[Maxm]: 阅读全文
posted @ 2016-08-25 19:31 pandaB 阅读(394) 评论(0) 推荐(0)
摘要:首先最简单的存图方式:邻接矩阵 mp[i][j]表示从i->j有一条边权为mp[i][j]的边//如果是无限大的话就是算作没有边 e.g.http://218.5.5.242:9018/JudgeOnline/problem.php?id=1144 这里mp[xx][yy]=(xx和yy的距离)// 阅读全文
posted @ 2016-08-24 18:03 pandaB 阅读(279) 评论(0) 推荐(0)