-
Notifications
You must be signed in to change notification settings - Fork 0
/
13023-ABCDE.py
47 lines (37 loc) · 995 Bytes
/
13023-ABCDE.py
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
43
44
45
46
47
def solve():
for i in range(len(edges)):
for j in range(len(edges)):
A, B = edges[i]
C, D = edges[j]
if A == C or A == D or B == C or B == D:
continue
if matrix[B][C] != 1:
continue
for E in lists[D]:
if E == A or E == B or E == C or E == D:
continue
print(1)
return
print(0)
if __name__ == '__main__':
N, M = map(int, input().split())
matrix = [[0] * (N) for _ in range(N)]
lists = [[] for _ in range(N)]
edges = []
for _ in range(M):
a, b = map(int, input().split())
matrix[a][b] = 1
matrix[b][a] = 1
lists[a].append(b)
lists[b].append(a)
edges.append((a, b))
edges.append((b, a))
solve()
# for m in matrix:
# print(m)
#
# for l in lists:
# print(l)
#
# for e in edges:
# print(e)