畅通工程续 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 50537    Accepted Submission(s): 18852 Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走…
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…
不写普通模板了,还是需要优先队列优化的昂 #include<stdio.h> //基本需要的头文件 #include<string.h> #include<queue> #include<algorithm> #include<vector> using namespace std; typedef pair<int,int> pii; const int INF=0x3f3f3f3f; ; ; ],val[maxm<<]…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意:找点1到点n的最短路(无向图) 练一下最短路... dijkstra+队列优化: #include<iostream> #include<functional> #include<vector> #include<queue> using namespace std; typedef pair<int, int> p;//first是…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1874 spfa 模板 #include<iostream> #include<stdio.h> #include<string.h> #include<queue> using namespace std; <<; ],d[],vis[],n,m; queue<int>q; struct node { int u,v,w,next; } ed…
http://acm.hdu.edu.cn/showproblem.php?pid=206 题意 从任意一个邻居家出发 到达任意一个终点的 最小距离 解析 求多源最短路 我想到的是Floyd算法 但是题目给出的n的大小不确定 所以图很稀疏 会有很多孤立点 会多跑很多没用的路径 需要优化一下 不然会超时 我看其他人很多都是用迪杰斯特拉写的,可以试试 AC代码 #include <stdio.h> #include <math.h> #include <string.h>…
2017-09-12 19:50:58 writer:pprp 最近刚开始接触拓扑排序,拓扑排序适用于:无圈图的顶点的一种排序, 用来解决有优先级别的排序问题,比如课程先修后修,排名等. 主要实现:用矩阵来储存图,用indegree数组记录每个顶点的入度, 从入度为0的开始,每次删除该入度为0的点,然后修改其他顶点的入度, 在进行查找入度为0的顶点,循环下去就可以 题意如下:给你n个队伍,m个优先顺序,让你输出总的排名的优先顺序. 代码如下: /* @theme:拓扑排序 hdu 1285 @w…
题目链接:http://poj.org/problem?id=3635 Description After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visited. Maybe you could have saved some money if you were…
题目链接:http://codeforces.com/gym/101873/problem/C 题意: 这是七月的又一个阳光灿烂的日子,你决定和你的小女儿一起度过快乐的一天.因为她真的很喜欢隔壁镇上的仙女公园,所以你决定到那儿去玩一天. 你妻子同意开车送你去公园接你.她非常准时,所以她确切地告诉你她什么时候会到公园的前门来接你,而你必须恰好在那个时间到那里.因为你显然也不想在外面等,这样会让你的小女儿伤心——她本可以在公园里多待些时间. 现在你必须考虑游玩计划.你知道你什么时候到达,什么时候离开…
Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project. The Marjar Empire has N cities (including the capital)…