随笔分类 - 最短路
摘要:题目链接:https://www.luogu.org/problemnew/show/P1073 对于状态量相互影响的题目,分层图是个不错的想法。 考虑在题目中分为: 不交易: 直接从1到n出去,为0 交易: 先在某点买入,再从该点后所在路径上卖出。 买入卖出是两个操作,考虑可以分开在两张图上做,于
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P3946 交好几遍是因为虽然能过一直有提醒..强迫症qwq include define ll long long using namespace std; const int maxn = 5 1e6 + 10
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P3393 被占领的点可以先连在一个点上然后只需要对这一个点bfs一遍就可以求所有的危险点 include define ll long long using namespace std; const int ma
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P3275 把不等式 A B 转化成 A B = 1或者 B A include include include include define ll long long using namespace std; c
阅读全文
摘要:无优化:500ms deque优化:400ms include include include include include using namespace std; const int maxn = 550000; const int inf = 0x7fffffff; int dis[maxn
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P2939 本来说是双倍经验题,跟飞行路线一样的,结果我飞行路线拿deque优化SPFA过了这里过不了了。 所以多学一种优先队列优化。 include include include include include
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P4568 卡了一晚上,算是分层图最短路的模板。注意卡SPFA,所以我写了个SLF优化。 同时 AC400祭!~ include include include include include define ri
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P1462 记住HP=0也叫死。 include include include include include using namespace std; const int maxn = 5000001; con
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P1186 邻接表开大开小真的奇妙,毒瘤玩意,再您妈的见。 include include include include include using namespace std; const int maxn =
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P1807 求最大路?就是把权值取相反数跑最短路。 include include include include include include using namespace std; const int ma
阅读全文
摘要:stl真是好,,偷懒少写邻接表,, 两个STL应用使代码简短了很多。然而还是那句话,天上不会掉馅饼,程序的效率还是有所下降的。然而,效率不是全部,人们宁可牺牲三倍效率用Java而不用C语言就是最好的例子(from_Charles E Leiserson_),具体取舍要看情况。 ——摘自luogu d
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P1144
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P1821 反向多存一个图,暴力跑两遍 Ctrl+C Ctrl+V 真毒瘤,弄得我12分反好几次,真是老年OI选手
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P2984 练习SPFA,把FJ当做起点,求出到所有牛的最短路,再把两个牛的相加。
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P3371 我永远都喜欢Flyod、dijkstra + heap、SPFA
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P3371#sub 堆优化迪杰斯特拉,留着以后复习用
阅读全文
摘要:题目链接:https://www.luogu.org/problemnew/show/P2299#sub 裸的迪杰斯特拉(我是在考试前复习一下板子)
阅读全文

浙公网安备 33010602011771号