
最短路
最短路
chr1st0pher
Dancer on the keyboard
展开
-
2020ICPC 江西省赛 K. Travel Expense(最短路+二分)
DescriptionHuanhuan is always working on fansy programming questions. However, today he decided to give himself a break and travel to a beautiful country. Therefore, another problem arose.There are totally n cities in the country. There are m two-way roa原创 2020-11-20 00:25:41 · 299 阅读 · 0 评论 -
2020ICPC·小米 网络选拔赛第一场 B. Intelligent Robot (计算几何+最短路)
DescriptionInput6 3 21 1 3 12 2 5 23 0 3 3Output3.8284Solution容易发现只有2*k+2个点可能做为路径上的拐点,在这些点上跑最短路即可建图时需要判断路径的合法性(即不会经过任意一堵墙)复杂度 = 建图复杂度O((2∗k+2)3)O((2*k+2)^3)O((2∗k+2)3) + (2∗k+2)(2*k+2)(2∗k+2)个点dijkstra复杂度Code#include <bits/stdc++.h>//p原创 2020-10-30 17:45:47 · 158 阅读 · 0 评论 -
Codeforces 954D. Fight Against Traffic (最短路)
DescriptionLittle town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these ro原创 2020-08-04 23:32:43 · 318 阅读 · 0 评论 -
Codeforces 296D. Greg and Graph (Floyd)
DescriptionGreg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game:The game consists of n s原创 2020-07-17 21:19:30 · 221 阅读 · 0 评论 -
Gym - 102174G 神圣的 F2 连接着我们 (线段树优化建图 + 多源最短路)
Description小白非常喜欢玩 “县际争霸” 这款游戏,虽然他的技术并不容乐观。“县际争霸” 的地图共有两个县,每个县里各有 nnn 个据点。同一个县之间的据点是互不连通的,两个县之间的据点也是互不连通的。小白的 ppp 个战斗单位在第一个县的第 x1,x2,⋯,xpx_1,x_2,⋯,x_px1,x2,⋯,xp 个据点中,而对手的 qqq 个建筑单位在第二个县第 y1,y2,⋯,yqy_1,y_2,⋯,y_qy1,y2,⋯,yq 个据点中。为了发起进攻,小白建造了很多的 “折跃棱镜”原创 2020-07-13 10:37:31 · 324 阅读 · 0 评论 -
2017 计蒜之道 复赛 百度地图导航 (超级节点最短路)
题目链接:Source题面:Solution暴力建边肯定不行,所以可以对每一个城市群建立一个超级出点和入点,内部城市到出点、入点到内部城市分别建耗费为0的边,城市群之间则按照出点->入点 入点 -> 出点 的规则建边,最后直接跑最短路即可Code#include <bits/stdc++.h>using namespace std;typedef long long ll;const int INF = 0x3f3f3f3f;const ll LINF = 0x3原创 2020-07-09 21:53:21 · 226 阅读 · 0 评论 -
Gym - 102448H Hellcife is on fire(多源最短路)
DescriptonThe kingdom of Hellcife has several cities that are connected by some roads. One day, the king of Hellcife, Bair Jolsonaro, decided to set fire on some of these cities, just for fun. It’s known that the i-th city has a number Ti, indicating that原创 2020-07-03 19:52:26 · 232 阅读 · 0 评论 -
BZOJ 4016 最短路径树问题(最短路 + 点分治)
题目链接:BZOJ 4016 / HDU 4871题目描述给一个包含nnn个点,mmm条边的无向连通图。从顶点1出发,往其余所有点分别走一次并返回。往某一个点走时,选择总长度最短的路径走。若有多条长度最短的路径,则选择经过的顶点序列字典序最小的那条路径(如路径A为1,32,11,路径B为1,3,2,11,路径B字典序较小。注意是序列的字典序的最小,而非路径中节点编号相连的字符串字典序最小)。到达该点后按原路返回,然后往其他点走,直到所有点都走过。可以知道,经过的边会构成一棵最短路径树。请问,在这棵原创 2020-06-25 01:07:54 · 276 阅读 · 0 评论 -
Codeforces Round #636 (Div. 3) E. Weights Distributing (BFS + 贪心)
Source题目大意:给定n个点m条边的无向无权图,以及m个价格,要你把m个价格分配给m条路,使得从a点走到b点,再从b点走到c点的总花费最小。解法:从a走到b,再走到c,显然都是原创 2020-06-09 16:28:35 · 142 阅读 · 0 评论 -
ICPC NEAU Programming Contest 2020 K. 关键结点 (最短路 + 割点)
解法:先用最短路求出每个点到点111和点nnn的距离dis1[],dis2[]dis1[], dis2[]dis1[],dis2[];若点u在最短路上则dis1[u]+dis2[u]==dis1[n]dis1[u] + dis2[u] == dis1[n]dis1[u]+dis2[u]==dis1[n]若边(u,v)(u,v)(u,v) 在最短路上则 dis1[u]+w+dis2[v]==dis1[n]dis1[u] + w + dis2[v] == dis1[n]dis1[u]+w+dis2[v].原创 2020-06-09 15:16:59 · 184 阅读 · 0 评论 -
HDU 1317 SPFA 判正环
SPFA它没死SourceSPFA判正环好题具体解释看注释:#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#define fuck cout ...原创 2019-06-10 22:56:07 · 186 阅读 · 0 评论