CCF 送货 + 欧拉路模板
2016-04-23 10:29
281 查看
#include <bits/stdc++.h> using namespace std; stack<int> st; vector<int> vec[10005]; bool mp[10005][10005]; int vis[10005],cp[10005]; int n,m; void pd(int a)//先判断是不是联通图 { cp[a]=1; vector<int>::iterator it; for(it=vec[a].begin();it!=vec[a].end();it++) { if(!cp[*it]) { pd(*it); } } } void DFS(int u) { for(int i = 0;i < vec[u].size();i++){ int v = vec[u][i]; if(mp[u][v]) //当一个节点的所有路径都被走过的时,压入栈中 { //越是先压入栈中的数据,越是需要后访问 mp[u][v]--; mp[v][u]--; DFS(v); } } st.push(u); } void put() { st.push(1); //因为DFS(int a)是压入起始点之后的节点,所以需要加入起始点 while(!st.empty()) { cout<<st.top()<<" "; st.pop(); } cout << endl; }
相关文章推荐
- 【数据库摘要】10_Sql_Create_Index
- [转]ubuntu下安装程序的三种方法
- git基础命令整理
- Light Bulb-------三分查找
- Spring JDBCの紹介
- 异步选择WSAAsyncSelect
- DAY8
- win10 + VS2010 + OpenCV2.4.10重编译OpenCV开发环境搭建
- Android中使用socket通信实现消息推送的方法详解
- ubuntu chrome
- 华为老总推荐的文章
- HDU 4358-I - Boring counting-dfs序+离线+树状数组/线段树
- poj-3050-Hopscotch
- Process, program, thread 的区别
- 338. Counting Bits
- Basemap可视化地图信息
- oj数据结构题谜之输出格式
- 图片的压缩优化
- BestCoder Round #81 (div.1) C Robot
- 一款实用的火车票订票APP--高铁管家