| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 7 | 3 | 3 | 60.000% |
Eric is a cool kid who just learned that a palindrome is a string that reads the same forward and backward. Recently, he found a string consisting of $n$ lowercase English letters. He immediately started looking for palindromic substrings in it (a substring is a contiguous sequence of characters within a string). He soon realized that the string did not contain very long palindromic substrings.
Eric wants to improve the situation by performing exactly one swap of two letters in the string (the letters must be at different positions). What is the length of the longest palindromic substring that can be obtained after Eric performs exactly one swap?
The input consists of a single string containing at least $2$ and at most $5\, 000$ lowercase English letters (a-z).
Output a single integer, the length of the longest palindromic substring that Eric can obtain after exactly one swap.
ccbaada
5
Eric can swap the first c with the first a, i.e., ccbaada. The resulting string is acbcada, which has a palindromic substring of length $5$: acbca.
ab
1
ICPC > Regionals > North America > Southeast USA Regional > 2025 Southeast USA Regional Programming Contest > Division 1 K번
ICPC > Regionals > North America > Southeast USA Regional > 2025 Southeast USA Regional Programming Contest > Division 2 K번
ICPC > Regionals > North America > South Central USA Regional > 2025 South Central USA Regional Contest > Division 1 K번
ICPC > Regionals > North America > South Central USA Regional > 2025 South Central USA Regional Contest > Division 2 K번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2025 Mid-Atlantic USA Regional Contest > Division 1 K번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2025 Mid-Atlantic USA Regional Contest > Division 2 K번