POJ 2230 Watchcow (欧拉回路模板)
来源:互联网 发布:伊犁知乎 编辑:程序博客网 时间:2024/06/06 03:03
题目大意:
求有向图欧拉路径的点序列。
解题思路:
欧拉回路模板。
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#include<map>#include<vector>#include<set>#include<ctime>#include<bitset>#define LL long long#define db double#define EPS 1e-15#define inf 1e10#define pa pair<int,int>using namespace std;const int maxn=50010;struct edge{ int to,next,w; bool flag;}e[2*maxn];int ans[2*maxn],head[2*maxn],cnt=0,ansi=0;void prepare(){ memset(head,-1,sizeof(head));}void add(int u,int v,int w){ e[cnt].to=v; e[cnt].next=head[u]; e[cnt].flag=0; head[u]=cnt++; e[cnt].to=u; e[cnt].next=head[v]; e[cnt].flag=0; head[v]=cnt++;}void dfs(int now){ for (int k=head[now];k!=-1;k=e[k].next){ if (!e[k].flag){ e[k].flag=1; dfs(e[k].to); } } ans[ansi++]=now;}int main(){ int n,m,u,v; prepare(); scanf("%d%d",&n,&m); for (int i=1;i<=m;i++){ scanf("%d%d",&u,&v); add(u,v,1); } dfs(1); for (int i=ansi-1;i>=0;i--) printf("%d\n",ans[i]); return 0;}
0 0
- POJ 2230 Watchcow (欧拉回路模板)
- poj 2230 Watchcow(欧拉回路)
- poj - 2230 - Watchcow(欧拉回路)
- POJ 2230 Watchcow(欧拉回路)
- POJ 2230 Watchcow (欧拉回路)
- POJ 2230 Watchcow 【欧拉回路】
- poj 2230 Watchcow (DFS + 欧拉回路)
- POJ 2230 Watchcow 欧拉回路题解
- [欧拉回路] poj 2230 Watchcow
- POJ 2230 Watchcow (欧拉回路)
- poj 2230 Watchcow 欧拉回路
- POJ 2230 Watchcow( 欧拉回路 )
- POJ 2230 Watchcow (欧拉回路)
- Poj 2230 Watchcow【欧拉回路】
- poj 2230 Watchcow(欧拉回路)
- POJ 2230 Watchcow 欧拉回路
- POJ 2330 Watchcow(欧拉回路)
- POJ 2230 Watchcow(欧拉回路+DFS)
- ORACLE禁用启用触发器
- caffe 中 protobuffer
- NLua Example
- Android控件绘制完成原来是这样的
- HttpWebRequest的GetResponse或GetRequestStream偶尔超时 + 总结各种超时死掉的可能和相应的解决办法
- POJ 2230 Watchcow (欧拉回路模板)
- 怎样只用4行代码编写出一个从字符串到长整形的函数?
- java基础知识复习
- iOS开发在项目中添加文件夹的步骤
- 算法杂项
- MD5码加密
- [软考]之软件过程模型I
- 设置sort_buffer_size
- 第001讲:我和Python的第一次亲密接触 | 课后测试题及答案