#P1120C. Compress String
Compress String
No submission language available for this problem.
Description
Suppose you are given a string of length consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent as a concatenation of several non-empty strings: . The -th of these strings should be encoded with one of the two ways:
- if , meaning that the current string consists of a single character, you can encode it paying coins;
- if is a substring of , then you can encode it paying coins.
A string is a substring of a string if can be obtained from by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
So your task is to calculate the minimum possible number of coins you need to spend in order to compress the given string .
The first line contains three positive integers, separated by spaces: , and () — the length of the string, the cost to compress a one-character string and the cost to compress a string that appeared before.
The second line contains a single string , consisting of lowercase English letters.
Output a single integer — the smallest possible number of coins you need to spend to compress .
Input
The first line contains three positive integers, separated by spaces: , and () — the length of the string, the cost to compress a one-character string and the cost to compress a string that appeared before.
The second line contains a single string , consisting of lowercase English letters.
Output
Output a single integer — the smallest possible number of coins you need to spend to compress .
Samples
Note
In the first sample case, you can set 'a', 'b', 'a' and pay coins, since is a substring of .
In the second sample, you just need to compress every character by itself.
In the third sample, you set 'a', 'aa' and pay coins, since is a substring of and is a substring of .