This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import sys
# sys.stdin = open("1.in", "r")
n, m = map(int, input().split())
paths = [set() for _ in range(n)]
for _ in range(m):
a, b = map(lambda x: int(x) - 1, input().split())
paths[a].add(b)
paths[b].add(a)
res = []
def solve(node):
while paths[node]:
top = paths[node].pop()
paths[top].remove(node)
solve(top)
res.append(node + 1)
solve(0)
print(*res)
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |