CCF 送货 + 欧拉路模板
生活随笔
收集整理的這篇文章主要介紹了
CCF 送货 + 欧拉路模板
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#include <bits/stdc++.h>
using namespace std;
stack<int> st;
vector<int> vec[];
bool mp[][];
int vis[],cp[];
int n,m; void pd(int a)//先判斷是不是聯(lián)通圖
{
cp[a]=;
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 = ;i < vec[u].size();i++){
int v = vec[u][i];
if(mp[u][v]) //當一個節(jié)點的所有路徑都被走過的時,壓入棧中
{ //越是先壓入棧中的數(shù)據(jù),越是需要后訪問
mp[u][v]--;
mp[v][u]--;
DFS(v); }
}
st.push(u);
}
void put()
{
st.push(); //因為DFS(int a)是壓入起始點之后的節(jié)點,所以需要加入起始點
while(!st.empty())
{
cout<<st.top()<<" ";
st.pop();
}
cout << endl;
}
總結(jié)
以上是生活随笔為你收集整理的CCF 送货 + 欧拉路模板的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2018-2019-2 网络对抗技术 2
- 下一篇: POJ 2299