Skip to content

[BOJ] 아기상어2 / 실버2 / 50분#79

Open
sondahyun wants to merge 1 commit into
cozykbin:mainfrom
sondahyun:main
Open

[BOJ] 아기상어2 / 실버2 / 50분#79
sondahyun wants to merge 1 commit into
cozykbin:mainfrom
sondahyun:main

Conversation

@sondahyun

Copy link
Copy Markdown

No description provided.

@sondahyun sondahyun changed the title Implement BFS to find maximum distance to sharks [BOJ] 아기상어2 / 실버2 / 50분 Nov 14, 2025
@ByeolNabi

Copy link
Copy Markdown
Collaborator

다현님, 코드 잘 봤습니다. dist 배열을 -1로 초기화해서 visited와 상어 위치를 합친 아이디어가 정말 좋네요. 이 아이디어 덕분에 map배열을 생략해서 메모리를 줄일 수 있을 것 같습니다!

마지막에 ans를 구할 때 이중 for문을 다시 돌리기보다, BFS안에서 ans = Math.max(ans, dist[x][y]) 형태로 거리를 구할 때 마다 최댓값을 저장하면 for문 한 바퀴를 줄일 수 있을 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants