Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions 81302_py_jy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
answer = []
#23점 코드입니다.
def dfs(m,x,y,flag,visitt):
if flag<=2 and m[y][x] != '1' and m[y][x] != 'X':
flag += 1
visitt.append(m[y][x])
m[y][x] = '1' #방문 표시
dfs(m,x+1,y,flag,visitt)
dfs(m,x-1,y,flag,visitt)
dfs(m,x,y+1,flag,visitt)
dfs(m,x,y-1,flag,visitt)
dfs(m,x+1,y+1,flag,visitt)
dfs(m,x-1,y-1,flag,visitt)
dfs(m,x-1,y+1,flag,visitt)
dfs(m,x+1,y-1,flag,visitt)
return visitt


def solution(places):
for m in places:
cnt = 1
m = list(map(list,m))
for i,m_x in enumerate(m):
for ii,m_y in enumerate(m_x) :
if m_y == 'P':
if i<0 or i>4 or ii<0 or ii>4:
break
else:
m_c = m.copy()
visittt = dfs(m_c,i,ii,0,[])
if visittt.count('P')>=2:
cnt = 0
break
if cnt == 0:
break
answer.append(cnt)
return answer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PXPXP ...일 때 정답은 1인데 0을 리턴합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!