Week10 정여진 9082 지뢰찾기 풀이 #163
Open
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.
풀이
문제에서 벗어나서 역으로 빈 배열(크기 6)에 지뢰를 하나씩 놓았을 때 숫자가 어떻게 변하는지를 생각함
두 가지 경우로 나눠서
##*###
3번째 위치에 놓으면
011100
숫자의 총 합이 3 증가함 (3군데의 숫자에 영향을 줌)
*#####
1번째 위치에 놓으면
110000
숫자의 총 합이 2 증가함 (2군데의 숫자에 영향을 줌)
즉, 입력의 숫자 줄의 총 합을 구해서 그 합이
느낀점
숫자를 보고 -> 지뢰가 어디 있는지 찾기 가 아니라 역으로
지뢰를 놓았을 때 -> 숫자가 어떻게 변하는지 를 생각하다가 아이디어가 떠올랐습니다
바로 떠올린 게 아니라 한참 생각하다가 나온 거라서
애드혹 문제는 아이디어가 안 떠오르면 어떻게 해야할지 모르겠네요