← All problemsSign in

Chef, Chefina and Their Friendship

CodeChefRating 1894Open on judge ↗

In Chefland, each person has their own non-empty personal string. When two people with personal strings $T_1$ and $T_2$ (possibly identical) become friends in Chefland, their strings are replaced by a new string $S = T_1 + T_1 + T_2 + T_2$, where $+$ denotes string concatenation. Chef recently became friends with Chefina. However, Chefina's personal string was her favourite and she got upset wh

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