Candidate | Softeer Assessment UI
Candidate | Softeer Assessment UI
softeer.ai
나의 코드
import sys
input = sys.stdin.readline
map_size, depth_size = list(map(int,input().split()))
#print(map_size, depth_size)
map_list = []
check_points = []
result = []
def dfs(point_list, depth):
if depth==depth_size:
return result.append(point_list)
elif point_list[-1]==check_points[depth]:
dfs(point_list, depth+1)
else:
for move in [(1,0),(-1,0),(0,1),(0,-1)]:
new_x = point_list[-1][0]+move[0]
new_y = point_list[-1][1]+move[1]
if 0<=new_x<map_size and 0<=new_y<map_size and map_list[new_x][new_y]!=1 and [new_x,new_y] not in point_list:
dfs(point_list + [[new_x,new_y]], depth)
for _ in range(map_size):
map_list.append(list(map(int,input().split())))
for _ in range(depth_size):
x,y = list(map(int,input().split()))
x-=1
y-=1
check_points.append([x,y])
dfs([check_points[0]],0)
#print(map_list, check_points)
print(len(result))'코딩테스트 파이썬 > Softeer' 카테고리의 다른 글
| Softeer 연습문제(3단계) - 스마트 물류 (0) | 2024.06.28 |
|---|---|
| Softeer 연습문제(3단계) - 플레이페어 암호 (1) | 2024.06.28 |
| Softeer 연습문제(3단계) - 나무 조경 (0) | 2024.06.28 |
| Softeer 연습문제(3단계) - 징검다리 (0) | 2024.06.27 |
| Softeer 연습문제(2단계) - 회의실 예약 (0) | 2024.06.26 |