Skip to content

Conversation

@lkhyun
Copy link
Contributor

@lkhyun lkhyun commented Jun 3, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/10942

🧭 풀이 시간

60분

👀 체감 난이도

✏️ 문제 설명

수열중 특정 구간이 팰린드롬인지 확인하는 문제.

🔍 풀이 방법

맨 끝만 비교하고 그 내부가 팰린드롬인지 아닌지를 dp로 저장해두고 사용했다.
1213121에서 2부터 6까지가 팰린드롬인지 아닌지를 판단할때, str[2] != str[6]이면 dp[2][6] = 0, str[2] == str[6] 이면 dp[3][5]의 값을 그대로 따라가는 방식.

⏳ 회고

문자열이 팰린드롬인지 아닌지 판단하는 건 O(N)
모든 부분 문자열에 대해서 팰린드롬인지 판단하는건 원래 O(N^3)인데, dp를 이용해서 O(N^2)까지 줄일 수 있음.
manacher 알고리즘을 사용하면 O(N+N)으로 가능한데 어려워서 포기함 ㅋ. 혁준이가 설명해주겠지?

@lkhyun lkhyun self-assigned this Jun 3, 2025
@lkhyun lkhyun added the hint 💡 반례를 참고했거나 힌트를 얻고 풀었을 때 label Jun 3, 2025
@lkhyun lkhyun merged commit 23592eb into main Jun 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hint 💡 반례를 참고했거나 힌트를 얻고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants