原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-andrew-stankevich-contest-22-asc-22-en.pdf 题意 给你一个无向图,要从1走到n,问你哪些边去掉之后就没法走原本的最短路了. 题解 跑两发最短路,顺着跑一发,倒着跑一发,对于边(u,v),如果w(u,v)+d[u]+rd[v]或者w(u,v)+d[v]+rd[u]…
题意:给你一幅图,问有多少条路径使得去掉该条路后最短路发生变化. 思路:先起始两点求两遍单源最短路,利用s[u] + t[v] + G[u][v] = dis 找出所有最短路径,构造新图.在新图中找到所有的桥输出就可以了. #include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque…
正反两次最短路用于判断边是不是最短路上的边,把最短路径上的边取出来建图.然后求割边.注意重边,和卡spfa. 正权,好好的dijkstra不用,用什么spfa? #include<bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define bug(x) cout<<#x<<'='<<x<<endl; #de…
C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88926#problem/C Description The city where Georgie lives has n junctions some of which are connected by bidirectional roads. Every d…
Important Roads Special JudgeTime Limit: 20000/10000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)     Problem Description The city where Georgie lives has n junctions some of which are connected by bidirectional roads.      Every day Geo…
Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with intege…
题目链接: 题目 D. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes inputstandard input outputstandard output 问题描述 In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbe…
题目链接: http://codeforces.com/contest/567/problem/E 题意: 给你一个带重边的图,求三类边: 在最短路构成的DAG图中,哪些边是必须经过的: 其他的(包括不在DAG上的边)不是必须经过的边把权值改小多少才能通过, 或者根本不可能通过的. 题解: 从起点s跑一遍最短路得到d[maxn],从终点t跑一遍最短路得到d2[maxn],对于边(u,v,w),如果d[u]+d2[v]+w==d[t]那么这条边在最短路上,对于不在最短路上的边,如果d[u]+d2[…
题意 题目链接 给出一张有向图,以及起点终点,判断每条边的状态: 是否一定在最短路上,是的话输出'YES' 如果不在最短路上,最少减去多少权值会使其在最短路上,如果减去后的权值\(< 1\),输出'NO',否则输出'CAN + 花费' Sol 考察对最短路的理解. 首先确定哪些边一定在最短路上,一个条件是 从起点到该点的最短路 + 边权 + 从该点到终点的最短路 = 从起点到终点的最短路 同时还要满足没有别的边可以代替这条边,可以用Tarjan求一下桥.当然也可以直接用最短路条数判 这样的话正反…
ROADS Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12436 Accepted: 4591 Description N cities named with numbers 1 - N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that…