> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/bfs-getting-minimum-value/untitled.md).

# MoveCrashingWall2

**알고리즘**

다음 이동할 좌표를 (nx,ny)라고 할 때 map\[nx]\[ny] == '1'일때랑 map\[nx]\[ny] == '0' 2가지 경우로 나눠서 푼다.\
첫번째 경우 벽 부순 횟수가 k보다 작으면 다음 좌표로 진행가능!

**틀린 부분**

1. map\[nx]\[ny] == '1'일 때 방문 체크하는 좌표값은 visited\[nx]\[ny]\[1]이 아니라\
   visited\[nx]\[ny]\[cur.dCnt+1]이 된다! 다음으로 이동할 좌표에 대해 중복 방문 여부 체크!!!

```java
if(map[nx][ny] == '1'){
    if(cur.dCnt<k && !visited[nx][ny][cur.dCnt+1]){
        q.add(new Point(nx,ny,cur.dCnt+1,cur.dist+1));
        visited[nx][ny][cur.dCnt+1] = true;
    }
}
```

2\. visited 배열 크기\
k는 벽을 부술 수 있는 횟수이다. k가 2라고 하면 k = 0->1->2 이런식으로 증가한다.\
그러므로 visited 배열방을 생성할 때 3번째 차원의 크기는 k+1 로 해주어야한다!
