-
Notifications
You must be signed in to change notification settings - Fork 0
/
boj_1389_quiz.py
42 lines (36 loc) · 1013 Bytes
/
boj_1389_quiz.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
import sys
from collections import deque
input = sys.stdin.readline
n, m = list(map(int, input().rstrip().split(" ")))
r = {}
for i in range(1, n + 1):
r[i] = []
for i in range(m):
f, t = list(map(int, input().rstrip().split(" ")))
r[f].append(t)
r[t].append(f)
print(r)
cur_visited = []
sum_list = [0] * (n + 1)
def find_num(count, start, init_num, to_find):
global sum_list
# print(count,start, to_find)
arr = r[start]
for num_to in arr:
if num_to == to_find:
sum_list[init_num] += count
print([count, start,init_num, to_find])
return
if num_to in cur_visited:
continue
cur_visited.append(num_to)
find_num(count + 1, num_to, init_num,to_find)
cur_visited.pop()
for i in range(1, n + 1):
for j in range(1, n + 1):
if i != j:
cur_visited.append(i)
print([i,j])
find_num(1, i, i, j)
cur_visited.pop()
print(sum_list)