题目链接:https://cn.vjudge.net/problem/POJ-1511 题意 给出一个图 求从节点1到任意节点的往返路程和 思路 没有考虑稀疏图,上手给了一个Dijsktra(按紫书上的存边方法) 直接超时 写了一个极限大小数据 发现读入时间很长,Dij时间也很长,相当于超时超到姥姥家了 赶紧做优化 发现稀疏图,于是换Bellman(spfa) 换邻接表 (虽然没有必要)scanf换成getchar输入模版,大量数据可以节省大概800ms的样子 稀疏图适用Bellman(opti…
题目链接:http://poj.org/problem?id=1511 题目大意:给你n个点,m条边(1<=n<=m<=1e6),每条边长度不超过1e9.问你从起点到各个点以及从各个点到起点的最小路程总和. 解题思路:这里用了优先队列优化的dijkstra复杂度mlogn,从起点到个点最短路径直接算就好了,算各个点到起点的最短路径,只要把边的方向反一下,再算一次从起点到个点最短路径就好了. Dijkstra: #include<iostream> #include<cs…
Invitation Cards 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/J Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater a…
In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the necessa…
Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 33435   Accepted: 11104 Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They wa…
题意: 给定n个点, m条路, 求1到 2 ~n的最短路之和加上2~n到1的最短路之和 分析: 裸最短路, 求其他点到源点的距离只需要把边方向再从源点求一次即可 spfa代码 #include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<cstdlib>…
POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径) Description In the age of television, not many people attend theater perfor…
Invitation Cards Time Limit : 16000/8000ms (Java/Other)   Memory Limit : 524288/262144K (Java/Other) Total Submission(s) : 7   Accepted Submission(s) : 1 Problem Description In the age of television, not many people attend theater performances. Antiq…
Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 16178   Accepted: 5262 Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They wan…
昨天的题太水了,堆优化跑的不爽,今天换了一个题,1000000个点,1000000条边= = 试一试邻接表 写的过程中遇到了一些问题,由于习惯于把数据结构封装在 struct 里,结果 int [1000000] 导致 struct 爆栈,此问题亟待解决.. 实力碾压SPFA 2500 ms,有图为证 #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #d…