Merged
Conversation
YoonYn9915
approved these changes
Jun 15, 2025
YoonYn9915
approved these changes
Jun 15, 2025
Member
YoonYn9915
left a comment
There was a problem hiding this comment.
그래프 탐색 문제에서 최소 시간 외에 다른 조건이 붙은 경우 어떻게 처리해야 할 지 연습이 된 좋은 문제 출제해주셔서 감사합니다!!
아직 방문하지 않은 경우, 이미 방문했지만 같은 시간에 또 다시 도달한 경우 경로를 어떻게 업데이트 할 지 떠올리는게 이 문제 핵심이었던 것 같은데 이 부분에서 잘못된 연산을 해서 문제를 못 풀었던 것 같아요. 예전에 동아리에서 이런 비슷한 문제를 했었는데 이번에 시간안에 못 풀어서 좀 아쉬웠습니다...
Collaborator
Author
아쉬웠을테지만 그래도 이번 기회에 복습하게 되었으니 다음에는 더 잘 푸실거예요! |
🔥2025-06 챌린지 진행 상황👉 그래프
👉 구현
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🌱WIL
🚀주간 목표 문제 수: 3개
백준 #12851. 숨바꼭질2: 그래프 / 골드4
정리한 링크: (바로가기)
🚩플로우 (선택)
MAX = 100000으로 문제에서 주어진 최대 범위를 설정한다.N, K를 입력받아 수빈이의 위치와 동생의 위치를 저장한다.dist: 각 위치까지 도달하는 최소 시간을 저장 (초기값 -1)ways: 각 위치까지 최소 시간으로 도달하는 방법의 수를 저장 (초기값 0)queue를 생성하고 시작점N을 넣는다.dist[N] = 0: 시작점은 0초에 도달ways[N] = 1: 시작 위치에는 한 가지 방법으로 도달x = queue.popleft(): 현재 위치를 꺼낸다.x - 1,x + 1,x * 20 ≤ nx ≤ 100000인 경우만 유효dist[nx] == -1이면 아직 방문하지 않은 곳이므로,dist[nx] = dist+ 1: 현재 위치에서 한 번 더 이동한 시간ways[nx] = ways[x]: 이전 위치까지 도달하는 모든 방법 수를 그대로 가져옴queue.append(nx)로 큐에 추가dist[nx] == dist+ 1이면,ways[nx] += ways[x]: 추가로 또 다른 경로가 생긴 것이므로 누적print(dist[K]): 동생 위치에 도달하는 최소 시간print(ways[K]): 해당 시간으로 동생에게 도달할 수 있는 방법 수🚩제출한 코드
💡TIL
백준 #1697. 숨바꼭질: 그래프 / 실버1
정리한 링크: (바로가기)
🚩플로우 (선택)
N, K를 입력받고 최대 크기인 100001만큼 방문 배열을 만든다.visited[N] = 0으로 시작 위치 설정N을 넣는다current를 꺼낸다current == K라면 탐색 종료current-1,current+1,current*2)를 모두 탐색visited[nx] = visited[current] + 1nx를 큐에 추가visited[K]값이 정답 (가장 빠르게 동생을 찾는 시간)🚩제출한 코드
💡TIL
백준 #20546. 기적의매매법: 구현 / 실버5
정리한 링크: (바로가기)
🚩플로우 (선택)
🚩제출한 코드
💡TIL