F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Typewriter

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1843    Accepted Submission(s): 519


Problem Description
One day, Jerry found a strange typewriter. This typewriter has $2$ input modes: pay $p$ coins to append an arbitrary single letter to the back, or $q$ coins to copy a substring that has already been outputted and paste it in the back.
Jerry now wants to write a letter to Tom. The letter is a string $S$ which contains only lowercase Latin letters. But as Jerry is not very wealthy, he wants to know the minimum number of coins he needs to write this letter.
 

Input
This problem contains multiple test cases. Process until the end of file.
For each test case, the first line contains string $S$ ($|S| \le 2 \times 10 ^ 5, \sum |S| \leq 5\times 10 ^ 6$), consisting of only lowercase Latin letters. And the second line contains $2$ integers $p$ and $q$ ($1 \leq p,q < 2^{31}$).
 

Output
For each test case, output one line containing the minimum number of coins Jerry needs to pay.
 

Sample Input
abc 1 2 aabaab 2 1
 

Sample Output
3 6
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-24 20:31:47, Gzip enabled