← All problemsSign in

Restrict Palindromes

CodeChefRating 1133Open on judge ↗

For a string $S$, we define $f(S)$ as the number of **distinct palindromic$^{\dagger}$ substrings$^{\ddagger}$** of $S$. For example, $f(abaa) = 4$ because we can find the palindrome substrings $a, b, aa$ and $aba$. Call a string $S$ good if $f(S) \le 5$, i.e. it has at most $5$ distinct palindrome substrings. You are given an integer $N$. Construct any good string of length $N$ using only lo

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start