-
Notifications
You must be signed in to change notification settings - Fork 0
/
bfs,dfs-2178.py
87 lines (72 loc) · 2.03 KB
/
bfs,dfs-2178.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# #1:이동가능, 0:불가능
# #(1,1)에서 출발
# import sys
# from collections import deque
# x,y=map(int, input().split())
# mat=[[0]*(y+1) for _ in range(x+1)]
# for i in range(x):
# m=sys.stdin.readline()
# for j in range(y):
# mat[i+1][j+1]=int(m[j])
# def find(start,end,cnt):
# while start!=x and end !=y:
# if mat[start][end+1]==1:
# if mat[start+1][end]==1:
# start+=1
# cnt+=1
# find(start,end,cnt)
# elif mat[start][end+1]==1:
# end+=1
# cnt+=1
# find(start,end,cnt)
# if mat[start+1][end]==1:
# if mat[start+1][end]==1:
# start+=1
# cnt+=1
# find(start,end,cnt)
# elif mat[start][end+1]==1:
# end+=1
# cnt+=1
# find(start,end,cnt)
# ans.append(cnt)
# ans=[]
# find(1,1,0)
# print(ans)
# #deque.popleft()
# # def find(start):
# # for i in range(1,y+1):
# # if mat[i][start]==1:
# # queue.append(i)
# # def find(start,cnt):
# # queue=deque([start])
# # while queue:
# # cnt+=1
# # # start=queue.popleft()
# # # check.append(start)
# # # for i in range(1,x+1):
# # # if mat[i][start]==1 and i not in check:
# # # queue.append(i)
# # def find(start,end,cnt):
# # #반복문 조건
# # while start!=4 and end!=6:
# # cnt+=1
# # if mat[start][end]==0:
# # continue
# # if mat[start+1][end]==1:
# # start+=1
# # find(start,end,cnt)
# # else:
# # end+=1
# # find(start,end,cnt)
# # if mat[start][end+1]:
# # end+=1
# # find(start,end,cnt)
# # else:
# # start+=1
# # find(start,end,cnt)
# # return cnt
# # find(1,1,0)
# # for m in mat:
# # for _ in m:
# # print(_, end=' ')
# # print()