#include<bits/stdc++.h>
#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vr(v) v.begin(),v.end()
#define rv(v) v.rbegin(),v.rend()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Davit cout.tie(NULL);
#define FOR(i, n) for(int i = 0;i<n;i++)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//#include "algo/debug.h"
const int N = 2e5 + 5;
int n, m;
vector<multiset<int>> gp;
vector<int> ans;
void dfs(int u) {
while ((int) gp[u].size()) {
int to = *gp[u].begin();
gp[u].erase(gp[u].find(to));
gp[to].erase(gp[to].find(u));
dfs(to);
}
ans.pb(u);
}
int main() {
// freopen("../input.txt", "r", stdin);
cin >> n >> m;
gp.resize(n);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
gp[u].insert(v);
gp[v].insert(u);
}
for (int i = 0; i < n; i++) {
ans = vector<int>();
dfs(i);
ans.pop_back();
for (auto x: ans)cout << x + 1 << " ";
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |