poj 1724 ROADS 很水的dfs】的更多相关文章

题意:给你N个城市和M条路和K块钱,每条路有话费,问你从1走到N的在K块钱内所能走的最短距离是多少 链接:http://poj.org/problem?id=1724 直接dfs搜一遍就是 代码: #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <stdlib.h> #include <vector> #i…
题意:给你N 城市和M条道路,每条道路要付的钱,但是如果你在这个道路上你可以付其他道路的钱(跟走到的时候去的话不一样),问你从1走到N最少话费是多少. 直接DFS搜. 链接http://poj.org/problem?id=3411 代码: #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <stdlib.h> #inc…
POJ 1724 ROADS Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12766   Accepted: 4722 Description N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it : the road length and…
ROADS Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10777   Accepted: 3961 Description N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll…
题目传送门 题意:问从1到n的最短路径,同时满足花费总值小于等于k 分析:深搜+剪枝,如果之前走过该点或者此时的路劲长度大于最小值就不进行搜索. /************************************************ * Author :Running_Time * Created Time :2015/11/11 星期三 10:14:14 * File Name :POJ_1724.cpp **************************************…
题目链接:http://poj.org/problem?id=1724 题目意思:给出一个含有N个点(编号从1~N).R条边的有向图.Bob 有 K 那么多的金钱,需要找一条从顶点1到顶点N的路径(每条边需要一定的花费),前提是这个总花费  <= K. 首先这里很感谢 yunyouxi0 ,也就是我们的ACM队长啦~~~,他一下子指出了我的错误——存储重边的错误.这条题卑鄙的地方是,有重边,discuss 中的数据过了也不一定会AC啦.大家不妨试试这组数据(队长深情奉献^_^) 2 2 2 1…
一道写法多样的题,很具有启发性. 具体参考:http://www.cnblogs.com/scau20110726/archive/2013/04/28/3050178.html http://blog.csdn.net/lyy289065406/article/details/6692382…
题目链接 题意 : 求从1城市到n城市的最短路.但是每条路有两个属性,一个是路长,一个是花费.要求在花费为K内,找到最短路. 思路 :这个题好像有很多种做法,我用了BFS+优先队列.崔老师真是千年不变的SPFA啊,链接.还有一个神用了好几种方法分析,链接 . 用优先队列控制长度,保证每次加的都是最短的,每次从队列中取元素,沿着取出来的点往下找,如果费用比K少再加入队列,否则不加,这样可以省时间. #include <stdio.h> #include <string.h> #inc…
题目链接: https://cn.vjudge.net/problem/POJ-1724 N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (expressed in the num…
Constructing Roads Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20889   Accepted: 8817 Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each…