最短路
七九河开
这个作者很懒,什么都没留下…
展开
-
Funny Car Racing UVA - 12661
There is a funny car racing in a city with n junctions and m directed roads. The funny part is: each road is open and closed periodically. Each road is associate with two integers (a, b), that means t...原创 2018-08-09 14:49:22 · 158 阅读 · 0 评论 -
最短路 dijkstra算法模板
计算单源最短路 不能计算负环 邻接矩阵 #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; typedef long long ll; #define...原创 2018-08-03 10:06:34 · 189 阅读 · 0 评论 -
最短路 floyd模板
多源最短路 简单 但复杂度高 #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <queue> #include <cstring> using namespace std; typedef lo...原创 2018-08-03 10:15:32 · 227 阅读 · 0 评论 -
最短路 bellman模板
int u[MAX,v[MAX],w[MAX]; int dist[MAX]; int n,m; void bellman(int vs) { int i,j,k; for(i=1;i<=n;i++) dist[i] = inf; dist[vs] = 0; for(k=1;k<=n-1;k++)//最多需要松弛n-1次 { ...原创 2018-08-03 10:37:01 · 209 阅读 · 0 评论 -
最短路 SPFA 模板
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <queue> #include <cstring> using namespace std; typedef long long ll; #defi...原创 2018-08-03 10:54:30 · 358 阅读 · 0 评论 -
Legacy CodeForces - 786B (线段树优化建边+)
题目 https://cn.vjudge.net/problem/CodeForces-786B 题意 最短路 思路 建两棵树 入树和出树 入树每个结点向孩子建边 出树向父亲建边 每棵树的叶子结点不能相互到达 只能通过新建的边到达 即最短路 #include <bits/stdc++.h> using namespace std; typedef long long ...原创 2019-05-06 16:20:38 · 253 阅读 · 0 评论 -
Shortest Cycle (最小环)
题目 https://codeforces.com/contest/1206/problem/D 题意 给你n个数 如果两个数 与运算 不为0 那么就存在一条边 问这n个数的最小环 思路 与运算不为0 即存在某一个二进制位都为1 让每个数与二进制为1的相连 如果每个二进制数为1的数存在三个以上 答案即为3 否则floyd跑最小环 注意 三倍的0x3f3f3f3f会爆int 代码 ...原创 2019-08-20 09:20:03 · 867 阅读 · 0 评论