Problem 2965 --Typewriter

2965: Typewriter

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
One day, Jerry found a strange typewriter. This typewriter has 22 input modes: pay pp coins to append an arbitrary single letter to the back, or qq 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 SS 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.
This problem contains multiple test cases. Process until the end of file. 
For each test case, the first line contains string SS (|S|≤2×105,∑|S|≤5×106|S|≤2×105,∑|S|≤5×106), consisting of only lowercase Latin letters. And the second line contains 22 integers pp and qq (1≤p,q<2311≤p,q<231).
For each test case, output one line containing the minimum number of coins Jerry needs to pay.
abc
1 2
aabaab
2 1
3
6

推荐代码 查看2965 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$400 $ms] 刘成健 460865 2019-09-04 10:36:14
内存最少[$49096 $KB] 淡意的温柔 605338 2020-07-03 14:54:12
第一AC 刘成健 460865 2019-09-04 10:36:14
第一挑战 刘成健 460865 2019-09-04 10:36:14

赛题来源/所属竞赛 2019 Multi-University Training Contest 1 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛