-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13023.py
More file actions
42 lines (28 loc) · 713 Bytes
/
13023.py
File metadata and controls
42 lines (28 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
sys.setrecursionlimit(100000)
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
result = 0
def dfs(s, graph, visited, depth):
global result
visited[s] = True
if depth < 5 and not graph[s]:
return
if depth == 5:
result = 1
return
for e in graph[s]:
if not visited[e]:
dfs(e, graph, visited, depth+1)
if result == 1:
return
visited[s] = False
for i in range(n):
visited = [False] * n
if not visited[i]:
dfs(i, graph, visited, 1)
print(result)