标签:blog io os for sp div on log amp
习题7-1,UVa208,Time:11.6
#include <iostream> #include <vector> #include <cstdio> using namespace std; vector<int>map[10005]; int vis[1005]; int dfs(int s, int t, int n, int tmp[]) { if(s == t) { cout<<"1"; for(int i = 1; i < n; i++) { cout<<" "<<tmp[i]; } cout<<endl; return 0; } for(int i = 0; i < map[s].size(); i++) { if(vis[map[s][i]]) continue; vis[map[s][i]] = 1; tmp[n] = map[s][i]; dfs(map[s][i], t, n+1, tmp); vis[map[s][i]] = 0; } } int main() { freopen("in.txt","r",stdin); int tmp[1005]; int x, y, n; while(cin>>n) { vis[1] = 1; while(cin>>x>>y && x && y) { map[x].push_back(y); map[y].push_back(x); } dfs(1, n, 1, tmp); } return 0; }
标签:blog io os for sp div on log amp
原文地址:http://www.cnblogs.com/you-well-day-fine/p/4079739.html