最短路
不拿牌不改名
ACM刚入门,博客写错了可以留言给我啊
展开
-
最短路计数 学习笔记
最短路计数最短路非常熟悉,但是最短路数量怎么计算呢?设一个计数数组sum[];以 dij 算法为例,当 p—>q 时,如果是可以更新最短路,那么 sum[q]=sum[p];如果不可以更新最短路,那么如果 dis[p]+edge[i].w==dis[q] ,说明 p 到 q 也是最短路,sum[q]+=sum[p] ;模板题:洛谷·P1608 路径统计代码:#include<bits/stdc++.h>#define LL long long#define pa pair原创 2020-06-11 21:36:26 · 428 阅读 · 0 评论 -
分层图+最短路 小雨坐地铁
小雨坐地铁分层图是什么?每个地铁线可以作为一层图,这一层所涉及的点都要重新编号(相当于离散化,或者叫hash),这样一来每层的点都没有联系了,那么换线怎么办?这个时候可以建立虚点,每个点都与没有重新编号的点连接,代表出站或者入站;图建完了就是裸的最短路;代码:#include<bits/stdc++.h>#define LL long long#define pa ...原创 2020-05-05 23:37:32 · 190 阅读 · 0 评论 -
最短路变式+思维 [USACO07OCT]Obstacle Course S(洛谷 P1649)
[USACO07OCT]Obstacle Course S题目描述Consider an N x N (1 <= N <= 100) square field composed of 1by 1 tiles. Some of these tiles are impassible by cows and are marked with an ‘x’ in this 5 by 5 f...原创 2020-04-06 17:58:22 · 291 阅读 · 0 评论 -
两种最短路算法总结
最短路算法这里只总结两种最短路算法,第一是:Dijkstra,第二是:SPFA;这两种算法都用了队列优化,Dijkstra是优先队列,SPFA是普通队列;Dijkstra先介绍第一种,也是用的最多的一种最短路算法:Dijkstra;这种算法的思想就是先根据给定的起点 s ,找到这个点 s 所能连的点,更新一下所能连到的点的路径,然后放入优先队列里面;优先队列维护两个东西,一个是起点 s...原创 2020-03-16 16:12:42 · 358 阅读 · 0 评论 -
Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) D题
Navigation SystemThe map of Bertown can be represented as a set of n intersections, numbered from 1 to n and connected by m one-way roads. It is possible to move along the roads from any intersection...原创 2020-03-02 17:38:07 · 342 阅读 · 0 评论 -
Ideal Path (UVA - 1599 )
Ideal PathNew labyrinth attraction is open in New Lostland amusement park. The labyrinth consists of n roomsconnected by m passages. Each passage is colored into some color ci. Visitors of the laby...原创 2019-12-11 16:21:37 · 244 阅读 · 0 评论 -
Jzzhu and Cities (CodeForces - 449B)
Jzzhu and CitiesJzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from ...原创 2019-11-22 17:39:45 · 242 阅读 · 0 评论 -
通往奥格瑞玛的道路(洛谷P1462)
P1462 通往奥格瑞玛的道路**题目链接**一道二分答案加最短路的问题,每次对钱进行二分,二分出最少的钱可以走到目的地。最短路我用的是dijkstra算法,算是刚学,一直卡在初始化,wa了无数次。每次二分进行判断要跑dijkstra时都要把dis数组进行初始化,dijkstra就不多说了,个人感觉堆优化的dijkstra就是优先队列+bfs;代码:#include<bits/std...原创 2019-08-09 21:22:28 · 302 阅读 · 0 评论