Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long double ld;
- typedef long long ll;
- int n, m, used[10050];
- vector<int> g[10050];
- void dfs(int v, int p = -1) {
- used[v] = 1;
- cout << v + 1 << endl;
- for (int u: g[v]) {
- if (used[u]) {
- if (u != p && used[u] == 1)
- cout << u + 1 << endl << v + 1 << endl;
- continue;
- }
- dfs(u, v);
- cout << v + 1 << endl;
- }
- used[v] = 2;
- }
- int main() {
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- cin >> n >> m;
- for (int i = 0; i < m; i++) {
- int u, v;
- cin >> u >> v;
- u--; v--;
- g[u].push_back(v);
- g[v].push_back(u);
- }
- cout << 2 * m << endl;
- dfs(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement