Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
📘 풀이한 문제
⭐ 문제에서 주로 사용한 알고리즘
📜 대략적인 코드 설명
재차 정리해서 풀어 보니 불필요하거나 중복된 부분을 찾는 등 오류가 있음을 발견할 수 있었습니다.
상근이는 특정한 시작점이 없고 바깥 어디에서나 접근할 수 있기 때문에, '*', '.', 알파벳 등으로 이루어진 인풋 데이터들은 배열의 1행, 1열부터 넣고 상근이는 0행 0열부터 BFS를 시작하면 편합니다.
BFS로 길을 탐색할 때, 해당 칸에 방문하였는데 문이었는데 열쇠가 없었을 경우 그
문의 위치를 저장해 둡니다. 그러다 열쇠를 만났을 경우, 그 열쇠로 열 수 있는방문했던 문의 위치를 모두 큐에 push 합니다. 방문은 했었지만 딸 수는 없었던 그 문에 열쇠를 가지고 간 다음, 다시 그 문부터 BFS를 하게끔 해야 하기 때문입니다.map과 큐를 사용했습니다.
(참고) 풀면서 왜 계속 통과가 안되는지 의문이었던 문제였습니다. 우선 이 문제는 BAPC 2013 기출문제라서 테스트 케이스 파일이 존재했기 때문에 그것과도 비교하면서 돌려 봤습니다. (테스트케이스는 http://2013.bapc.eu/docs/preliminary.zip 에서 받을 수 있으며 이 문제는 K번 문제입니다.) 그러나 백준에서는 위에서 제공하는 테스트케이스 외에도 다른 코너 케이스가 추가로 존재하기 때문에 위의 것을 다 맞았다고 해서 백준에서 통과되지는 않았습니다.