标签:
Time Limit: 3000MS | Memory Limit: 65536K | |||
Total Submissions: 6255 | Accepted: 2708 | Special Judge |
Description
Input
Output
Sample Input
4 5 1 2 1 4 2 3 2 4 3 4
Sample Output
1 2 3 4 2 1 4 3 2 4 1
Hint
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<cstdlib> #include<algorithm> #include<queue> #include<vector> #include<stack> using namespace std; int n,m; vector<int> e[10010]; bool vis[10010]; void dfs(int u) { for(int i=0;i<e[u].size();i++) { int v=e[u][i]; if(v!=-1) { e[u][i]=-1; dfs(v); } } printf("%d\n",u); } int main() { int x,y; memset(vis,0,sizeof(vis)); scanf("%d%d",&n,&m); for(int i=0;i<m;i++) { scanf("%d%d",&x,&y); e[x].push_back(y); e[y].push_back(x); } dfs(1); return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4397210.html