Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I am Hunting High and Low
- Diving from the sky above
- Looking for, more and more, once again
- I'm Hunting High and Low
- Sometimes I may win, sometimes I'll lose
- It's just a game that I play
- After the storm there's a calm
- Through the clouds shines a ray of the sun
- I'm carried from all my harm
- There is no one I can't outrun
- Now I'm leaving my worries behind
- Feel the freedom of body and mind
- I'm starting my journey, I'm drifting away with the wind, I go___________________:-
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int N = 100+7;
- vector < int > v[N], euler;
- int vis[N];
- void dfs(int node){
- vis[node] = 1;
- euler.push_back(node);
- for(auto i : v[node]){
- if(!vis[i]){
- dfs(i);
- euler.push_back(node);
- }
- }
- }
- int main(){
- ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
- int n, i, q, l, r;
- cin >> n >> q;
- for(i = 1; i <= q; i++){
- cin >> l >> r;
- v[l].push_back(r);
- v[r].push_back(l);
- }
- dfs(1);
- for(int x : euler)cout << x << ' ';
- return 0;
- }
Add Comment
Please, Sign In to add comment