[20251212] BOJ / G4 / 인접한 비트의 개수 / 이준희#1652
Merged
ShinHeeEul merged 1 commit intomainfrom Dec 12, 2025
Merged
Conversation
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.
🧷 문제 링크
https://www.acmicpc.net/problem/2698
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
0과 1로 이루어진 수열 S에서 인접한 비트의 개수는 아래와 같습니다.
s1s2 + s2s3 + s3*s4 + ... + sn-1 * sn = k
N길이의 수열에서 인접한 비트의 개수가 K개가 되는 경우의 수를 구하는 문제입니다.
🔍 풀이 방법
DP를 이용해서 풀었습니다.
N길이의 수열에서 K번째 인덱스까지 봤을 때 인접한 비트의 개수를 DP로 구했습니다.
dp[n][k][0] 은 k번째가 0이었을 때이고
dp[n][k][1] 은 k번째가 1이었을 때를 의미합니다.
이를 이용하여 3차원 dp를 사용했습니다.
⏳ 회고
수식만 이해해도 풀 수 있는 문제였습니다.