您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: