#include <bits/stdc++.h>
using namespace std;
vector<set<int>> E;
void dfs(int u, int s)
{
int v = *E[u].begin();
E[u].erase(E[u].begin());
E[v].erase(E[v].find(u));
if(v == s)
{
cout<<u<<' ';
return;
}
dfs(v, s);
cout<<u<<' ';
}
int main()
{
int N,M;
cin>>N>>M;
E.assign(N+1,{});
for(int i=0; i<M; i++)
{
int u,v;
cin>>u>>v;
E[u].insert(v);
E[v].insert(u);
}
for(int i=1; i<=N; i++)
{
if(E[i].size() > 1)
{
dfs(i,i);
cout<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |