Codeforces 95C Volleyball(最短路)】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/95/C C. Volleyball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves volleyball very much. One day he was running late for a volleyb…
题目链接:http://codeforces.com/contest/95/problem/C 思路:首先dijkstra预处理出每个顶点到其他顶点的最短距离,然后如果该出租车到某个顶点的距离小于等于最短距离,就连边,费用为一开始出租车所需的费用,建好图之后再求一次最短路即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <…
[题目链接]:http://codeforces.com/problemset/problem/95/C [题意] 给你n个点,m条边; 每个点有一辆出租车; 可以到达离这个点距离不超过u的点,且在这个距离范围里面,路费都是v; 问你从起点到终点的最小花费; [题解] 重新建图; 每个点; 连一条边到这个点的出租车能够到达的点(从每个点求最短路); 然后边权都是v; 然后在从这个新建的图上从起点开始跑最短路; [Number Of WA] 0 [完整代码] #include <bits/stdc…
http://codeforces.com/contest/716/problem/D 题目大意:给你一些边,有权值,权值为0的表示目前该边不存在,但是可以把0修改成另外一个权值.现在,我们重新建路,问让s-t的最短路能否刚好是L? 思路:暴力修改即可... //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++.h> using namespace std; #define LL long long #define AL…
Petya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city has n junctions, some of which are connected by two-way roads. The length of each ro…
大意: n结点有向有权图, m个操作, 增加若干边的权重或询问源点为1的单源最短路. 本题一个特殊点在于每次只增加边权, 并且边权增加值很小, 询问量也很小. 我们可以用johnson的思想, 转化为差值最短路, 这样边权就在n-1以内, 可以直接暴力跑桶优化dijkstra. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <s…
F - Roads in Berland Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 25C Description There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each…
大意: 有向图, 求找4个不同的点ABCD, 使得d(A,B)+d(D,C)+d(C,A)最大…
Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supply from so…
题意: 给你一副图,给出的点两两之间的距离是abs(pos1-pos2),然后给你n个数是表示该pos到x的距离是1. 思路: 直接建边,跑spfa就好了.虽然说似乎题意说边很多,其实只要建一下相邻的点的边就好了,这样的图的性质还是得到了: // d*##$. // zP"""""$e. $" $o //4$ '$ $" $ //'$ '$ J$ $F // 'b $k $> $ // $k $r J$ d$ // '$ $ $&…