A62 - Depth First Search
提出
TLE
code: python
n, m = map(int, input().split())
g = {}
for i in range(1, n+1):
for a, b in ab:
while len(now):
next = now.pop(0)
continue
else:
continue
now.append(v)
print("The graph is connected.") if sum(visited) -1 == n else print("The graph is not connected.")
メモ
deque 使ったら AC
code: python
from collections import deque
n, m = map(int, input().split())
g = {}
for i in range(1, n+1):
for a, b in ab:
while len(now):
next = now.popleft()
continue
else:
continue
now.append(v)
print("The graph is connected.") if sum(visited) -1 == n else print("The graph is not connected.")