A radio station needs to transmit a message to several recipients. To ensure all listeners get it, the message is played again and again in a continuous loop.
You’re given a sequence of characters received by one of the recipients. It is known the sequence is at least as long as the message.
Your task is to write a program that extracts the message transmitted by the station. More formally, your program needs to find the shortest subsequence S′ of the input sequence S such that S in turn is a subsequence of the (sufficiently long) repetition S′ + S′ + ··· + S′.
입력 8 cabcabca 출력 3 The message could be abc, cab or abcabc, but there’s no possible message shorter than 3 characters.
출처: boi 2009 practice