CCF 送货 + 欧拉路模板

#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; }
原文地址:https://www.cnblogs.com/Norlan/p/5373604.html