ZOJ3378 两点间的必经之路 tarjan算法
来源:互联网 发布:百雀羚小雀幸面膜 知乎 编辑:程序博客网 时间:2024/05/26 09:55
Attack the NEET Princess
Time Limit: 9 Seconds Memory Limit:65536 KB
Houraisan Kaguya (蓬萊山輝夜) is theNEET (not in education, employment or training) princess living in Eientei(永遠亭). She is an unemployed geek, who sits at home andsurfs the Internet all day. But today is different, as the Hakurei ShrineReitaisai Festival (博麗神社例大祭) will be hosted in HakureiShrine, Kaguya decides to go to buy some new doujin games.
Fujiwara no Mokou (藤原妹紅) detestsKaguya, and has been planing to attack her for a long time. But she nerver gotthe chance before because Kaguya kept staying in Eientei, under theprotection of Yagokoro Eirin (八意永琳). Knowing thatKaguya will go outside today, Mokou decides to wait on certain road and attackher once she passes there. Mokou don't know which path Kaguya will choose, butshe thinks that there always exits some roads where she can always meet Kaguya.
Input
There are multiple cases. Each case begins with two integers 2 ≤ n≤ 10000 -- the number of villages and 2 ≤ m ≤ 100000 -- the number ofroads. Then m lines, each contains two integers a and b (0≤ a, b < n), indicating a road connecting village a andvillage b. Village 0 is Eientei and Village n-1 is HakureiShrine. They are always connected by roads. There may be more than oneroads between two villages.
Output
Find out the roads where Mokou can always meet Kaguya. For each case,output the number of roads in the first line, then output the numbers of theroads in ascending order in the second line.
Sample Input
3 2
0 1
1 2
7 8
0 1
0 2
1 3
2 3
3 4
3 5
4 6
5 6
Sample Output
2
0 1
0
求起点到终点之间的必经之路,思路是:首先用tarjan算法求出图中的所有割边,然后从起点开始BFS到终点搜出一条路径,把路径上的边和已求出的割边求交集就可以得出必经之路.
代码如下:
- ZOJ3378 两点间的必经之路 tarjan算法
- ZOJ3378
- 游戏与算法的必经之路
- 游戏与算法的必经之路!
- 游戏与算法的必经之路
- hdu2586 树上两点之间的距离 tarjan
- 两点间所有路径的遍历算法
- Tarjan算法的改装
- tarjan算法的实现
- tarjan算法的心得
- LCA的Tarjan算法
- tarjan算法的详解
- 计算GPS两点间的距离的几种算法
- 计算地球上两点间的距离算法代码
- 任意两点间的最短路径---floyd_warshall算法
- 求两点间所有路径的遍历算法
- floyd算法(求任意两点间的最短路径)
- 【离散数学实验】Dijkstra算法求指定两点间的距离
- Max Angle //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
- 疯狂的一周!
- c/c++ 实现简单的数组表-Zre0
- ZOJ2588 无向图求割边 tarjan算法
- 使用LauchPopupListener过滤lov数据
- ZOJ3378 两点间的必经之路 tarjan算法
- Google Tasks Chrome 插件
- Hadoop和HBase安装部署白皮书
- 使用Eclipse3.2(MyEclipse)+ abator自动生成iBatis代码以及配置文件的方法
- JAX-WS 异步调用
- 任意层节点的折叠
- HDU1358 字符串求周期 KMP算法
- 解析Windows2000的IDT扩展机制
- event.srcElement 与event.target