HDOJ5876(补图的最短路)】的更多相关文章

Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1563    Accepted Submission(s): 549 Problem Description In graph theory, the complement of a graph G is a graph H on the same verti…
In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in G. Now you are given an undirected graph G of N nodes and M bidirectional edges o…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5876 题意:有一个含有n个点的无向图,已知图的补图含有m条边u, v:求在原图中,起点s到其他n-1个点的最短距离,默认边的距离为1: 由于点的个数较大,不能建原图,只能从补图入手:从起点s开始,与s不直接相连的点的最短距离是1,然后再从这些点开始搜,循环即可,用队列表示,队列空了就结束了: #include<stdio.h> #include<string.h> #inc…
---恢复内容开始--- Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2590    Accepted Submission(s): 902 Problem Description In graph theory, the complement of a graph G is a graph H on t…
Travel The country frog lives in has nn towns which are conveniently numbered by 1,2,…,n. Among n(n−1) / 2 pairs of towns, m of them are connected by bidirectional highway, which needs aa minutes to travel. The other pairs are connected by railway, w…
线图 题目描述 九条可怜是一个热爱出题的女孩子. 今天可怜想要出一道和图论相关的题.在一张无向图 $G$ 上,我们可以对它进行一些非常有趣的变换,比如说对偶,又或者说取补.这样的操作往往可以赋予一些传统的问题新的活力.例如求补图的连通性.补图的最短路等等,都是非常有趣的问题. 最近可怜知道了一种新的变换:求原图的线图 (line graph).对于无向图 $G = ⟨V, E⟩$,它的 线图 $L(G)$ 也是一个无向图: 它的点集大小为 $|E|$,每个点唯一对应着原图的一条边. 两个点之间有…
1137: [POI2009]Wsp 岛屿 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 165  Solved: 78[Submit][Status][Discuss] Description Byteotia岛屿是一个凸多边形.城市全都在海岸上.按顺时针编号1到n.任意两个城市之间都有一条笔直的道路相连.道路相交处可以自由穿行.有一些道路被游击队控制了,不能走,但是可以经过这条道路与未被控制的道路的交点.问…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 689    Accepted Submission(s): 238 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertic…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意: 在补图中求s到其余各个点的最短路. 思路:因为这道题目每条边的距离都是1,所以可以直接用bfs来做. 处理的方法是开两个集合,一个存储当前顶点可以到达的点,另一个存储当前顶点不能到达的点.如果可以到达,那肯定由该顶点到达是最短的,如果不能,那就留着下一次再判. #include<iostream> #include<algorithm> #include<cstring>…
Travel The country frog lives in has \(n\) towns which are conveniently numbered by \(1, 2, \dots, n\). Among \(\frac{n(n - 1)}{2}\) pairs of towns, \(m\) of them are connected by bidirectional highway, which needs \(a\) minutes to travel. The other…