#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx=2e5+5;
vector<pair<int,int>> g[mx],edges;
bool used[mx];
int n,m;
vector<int> path;
void dfs(int u) {
while(!g[u].empty()) {
pair<int,int> cur = g[u].back();
g[u].pop_back();
if(used[cur.second]) continue;
used[cur.second] = true;
dfs(cur.first);
}
path.push_back(u);
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i=1;i<=m;++i) {
int u,v; cin >> u >> v;
edges.push_back({u,v});
g[u].push_back({v,i});
g[v].push_back({u,i});
}
dfs(1);
for(auto i:path) {
cout << i << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Same junction appears twice in a route |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Same junction appears twice in a route |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Same junction appears twice in a route |
2 |
Halted |
0 ms |
0 KB |
- |