HBC244822使徒袭来,数学,思维Type The Strings题解

柳絮泡泡 算法基础篇 64 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。
. Now she wants to type them on the txt-editor ., which Alice has typed before , then paste it into a single line (this will cost. S , Alice can perform the following operation any time to get. Now Alice wants to type all the strings , please help her to find the minimum cost .

Alice have n n strings named S_1 S 1 ​ to S_n S n ​ . Each string has a length l_i l i ​ . Now she wants to type them on the txt-editor (Sequence not required). For each string S_i S i ​ , she has two choice. The first choice is to type all characters of S_i S i ​ one by one (this will cost l_i l i ​ ). The second choice is to choose one string S_j S j ​ , which Alice has typed before , then paste it into a single line (this will cost k k) . Now we call this string S S , Alice can perform the following operation any time to get S_i S i ​ . - Delete any character from S S , each character costs 1 1 . - Insert any character anywhere in S S , each character costs 1 1 . Such as we want to get abac abac from bdc bdc , we will do the following operations : 1. Paste bdc bdc into a new line , cost k k . 2. Delete the 2nd 2nd character d d in bdc bdc to get bc bc , cost 1 1 . 3. Insert a a before the first character of bc bc to get abc abc , cost 1 1 . 4. Insert a a after the second character of abc abc to get abac abac , cost 1 1 . Totally cost k+3 k+3 . Now Alice wants to type all the strings , please help her to find the minimum cost .

HBC244822使徒袭来,数学,思维Type The Strings题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC244822使徒袭来 数学 思维Type The Strings题解