POJ 2230 无向图欧拉环
来源:互联网 发布:中学生学什么编程语言 编辑:程序博客网 时间:2024/04/28 19:20
题意简述
打印能遍历无向图所有边恰一次的一种方案。
分析
无向图欧拉环模板题,DFS过程中直接倒序输出已访问顶点的编号,最后再加上起点即可。
代码实现
type edge=record re,next:longintend;varn,m,cnt,i,x,y:longint;f:array[0..10010] of longint;e:array[0..100050] of edge;vs:array[0..100050] of boolean;procedure add(x,y:longint);begin inc(cnt); with e[cnt] do begin re:=y;next:=f[x]; end; f[x]:=cnt;end;procedure dfs(x:longint);var tmp:longint;begin tmp:=f[x]; while tmp<>0 do begin if not vs[tmp] then begin vs[tmp]:=true; dfs(e[tmp].re); writeln(e[tmp].re); end; tmp:=e[tmp].next; end;end;begin readln(n,m);cnt:=1; for i:=1 to m do begin readln(x,y); add(x,y);add(y,x); end; dfs(1); writeln(1);end.
0 0
- POJ 2230 无向图欧拉环
- poj 3352 无向图
- poj 2230 Watchcow 无向欧拉回路求路径
- POJ 1041 无向图的欧拉回路
- poj 3895 【无向图最大环】
- poj 2914 无向图最小割
- POJ-2914-无向图最小割
- poj 1523 SPF 无向图关节点
- POJ-2455-无向图网络流
- 【最小边覆盖 && 无向图】POJ
- 有向图,无向图的欧拉回路和欧拉通路poj 2337
- poj 1515 Street Directions(无向图改有向图)
- POJ - 1515 Street Directions(无向图变有向图)
- POJ 1523 无向图求割点
- POJ 1523 无向图割点
- POJ 2914 Minimum Cut //无向图求最小割
- poj 2914 Minimum Cut 无向图最小割
- poj 1966 无向图的点连通度
- hdu 5489 Removed Interval(线段树+LIS)
- QT 布局管理器的嵌套使用
- 关于openstack magnum的介绍
- matlab学习笔记
- Uva437 The Tower of Babylon
- POJ 2230 无向图欧拉环
- java robot机器人
- C++容器(四):map类型
- java设计模式前奏+jvm简介+数据结构字符串的复习
- JAVA_SE基础——35.static修饰成员函数
- CentOS系统如何与VirtualBox虚拟机共享文件夹
- 林冉CG写实绘画网络班视频教程-课堂录屏
- Codeforces Round #321 (Div. 2) D. Kefa and Dishes 位 状态压缩 dp
- C++学习书籍