poj 2230 Watchcow(深搜打印从1开始访问每个点2次再回到1的序列)
来源:互联网 发布:mysql 最后一行合计 编辑:程序博客网 时间:2024/04/29 02:57
题目地址
题目大意:给出n和m,代表有n个点,m条路,输入m条路,输出从1开始访问n个点,保证每个点访问2次,最终再回到1的次序
解题思路:按照点之间边的关系深搜
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <queue>#include <map>#include <string>#include <cstdlib>#include <ctime>using namespace std;const int MAX = 10000 + 10;int m,n;struct EDGE{ int v; bool flag; // 边的访问标志};vector<EDGE> vec[MAX];void dfs(int x){ for (int i=0; i<vec[x].size(); ++i) { if (!vec[x][i].flag) { vec[x][i].flag = true; dfs(vec[x][i].v); } } printf("%d\n", x);}int main(){ int u, v; EDGE temp; while (scanf("%d%d",&n, &m) != EOF) { for (int i=0; i<m; ++i) { scanf("%d%d", &u, &v); temp.v = v; temp.flag = false; vec[u].push_back(temp); temp.v = u; vec[v].push_back(temp); } dfs(1); } return 0;}
0 0
- poj 2230 Watchcow(深搜打印从1开始访问每个点2次再回到1的序列)
- poj 2330 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 2230 Watchcow
- POJ-2230-Watchcow
- poj 2230 Watchcow
- POJ 2230 Watchcow
- poj 2230 Watchcow
- POJ - 2230 Watchcow
- POJ 2230 Watchcow
- poj 2230 Watchcow
- netty程序源码句子解析
- 2015-08-06
- Android 中怎样查找SELinux导致的权限受限问题
- java 希尔排序
- Android 手把手教您自定义ViewGroup(一)
- poj 2230 Watchcow(深搜打印从1开始访问每个点2次再回到1的序列)
- CSU 1505 酷酷的单词
- jQuery1.9.1针对checkbox的调整
- java代码--回文
- [IOS 开发] XCTAssert单元测试
- SAPUI5 Table
- iOS开发——如何切图适配各种机型
- 通讯录系统 (C语言 控制台应用程序)
- 使用cocoaPods,pch提示找不到文件或者导入文件不智能索引的解决方案