典型的最短路问题,但是多了一个条件,就是每个点属于一个layer,相邻的layer移动,如x层移到x+1层需要花费c. 一种显而易见的转化是我把这些边都建出来,但是最后可能会使得边变成O(n^2); 网上看到的一些做法就是拆点,假如我给每层做一个平台点,所有点都可以到这个平台,然后再换乘到别的平台里不就可以了吗? 所以对于属于第i层的点我们构造一个i层点的虚拟点,把这些点连到这个平台点,花费为0,相邻平台点之间的花费为c不就可以了吗? 但是问题就出现在这里了,这样的话同一层的点的花费就会变成0,…
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4297574.html      ---by 墨染之樱花 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4725 题目描述:给一张图,每个点(1~N)都属于一个层(1~N),比如点1在第5层,点3在第4层,点4也在第5层.任何在x层的点都可以移动到x+1层和x-1层中的任何点上,并且需要耗费C的权值.除此之外,另外再给出M条带权无向边.求点1到点…
题目链接: Hdu 4725 The Shortest Path in Nya Graph 题目描述: 有n个点,m条边,每经过路i需要wi元.并且每一个点都有自己所在的层.一个点都乡里的层需要花费c元,问从1到N最小花费? 解题思路: 建图比较楠,刚开始的时候想到拆点,把一个点拆成两个,N+i表示点i所在层,对每个点对自己所在层建双向边,权值为0. 然后相邻层建双向边,权值为c.对w条点之间的边,正常建.但是写出来样例都GG了.发现对于同一层的点,在我建的图中可以免费来回跑,这样好像和题意有些…
The Shortest Path in Nya Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13070    Accepted Submission(s): 2794 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4725 Description: This is a ve…
HDU 4725 The Shortest Path in Nya Graph : http://acm.hdu.edu.cn/showproblem.php?pid=4725 题意: 在一个图中跑最短路,这个图中的每一个点都有一个等级,每次都只能向高一个等级或低一个等级的点跑.问最短的距离. 思路: 参考/kuangbin 这道题自己一开始直接按等级枚举,发现这样的复杂度是n*n的.需要更加合理的建图.考虑给每个等级建立两个点,一个用于进,一个用于出. 第i层,入边到N+2*i-1, 出边从N…
The Shortest Path in Nya Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11694    Accepted Submission(s): 2537 Problem Description This is a very easy problem, your task is just calculate…
The Shortest Path in Nya Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 37    Accepted Submission(s): 6 Problem Description This is a very easy problem, your task is just calculate el cam…
HDU - 4725 The Shortest Path in Nya Graph http://acm.hdu.edu.cn/showproblem.php?pid=4725 This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you do not und…
Description This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you do not understand a word of this paragraph, just move on.        The Nya graph is an un…
This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you do not understand a word of this paragraph, just move on. The Nya graph is an undirected graph with…