会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
·″咖啡ˇ
博客园
首页
新随笔
联系
订阅
管理
poj[2230]Watchcow 深搜 欧拉回路
在博客里写个做题记录,目的就是希望能够认识更多的大牛们~~
题目要求是一个人要走遍一个农场,每条路都要走两次,但每次的方向都不同。其实就是给定n个点,m条边,双向欧拉回路。
Code
1
#line
5"2230.cpp"
2
#include
<
iostream
>
3
#include
<
vector
>
4
using
namespace
std;
5
struct
edge
6
{
7
int
v;
8
bool
flag;
9
};
10
struct
edge temp;
11
vector
<
edge
>
map[
10001
];
12
void
DFS(
int
x)
13
{
14
int
i,j;
15
for
(i
=
0
; i
<
map[x].size(); i
++
)
16
{
17
if
(map[x][i].flag
==
false
)
18
{
19
map[x][i].flag
=
true
;
20
DFS(map[x][i].v);
21
}
22
}
23
cout
<<
x
<<
endl;
24
}
25
int
main()
26
{
27
int
m,n,i,a,b;
28
while
(cin
>>
n
>>
m)
29
{
30
for
(i
=
0
; i
<
m; i
++
)
31
{
32
cin
>>
a
>>
b;
33
temp.v
=
a;
34
temp.flag
=
false
;
35
map[b].push_back(temp);
36
temp.v
=
b;
37
temp.flag
=
false
;
38
map[a].push_back(temp);
39
}
40
DFS(
1
);
41
}
42
return
0
;
43
}
posted on
2009-10-16 14:21
over
阅读(
379
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部