CF67C.Sequence of Balls
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a sequence of balls A by your teacher, each labeled with a lowercase Latin letter 'a'-'z'. You don't like the given sequence. You want to change it into a new sequence, B that suits you better. So, you allow yourself four operations:
- You can insert any ball with any label into the sequence at any position.
- You can delete (remove) any ball from any position.
- You can replace any ball with any other ball.
- You can exchange (swap) two adjacent balls.
Your teacher now places time constraints on each operation, meaning that an operation can only be performed in certain time. So, the first operation takes time t__i, the second one takes t__d, the third one takes t__r and the fourth one takes t__e. Also, it is given that 2·t__e ≥ t__i + t__d.
Find the minimal time to convert the sequence A to the sequence B.
老师给了你一个球的序列 A,每个球标有一个小写拉丁字母 'a'–'z'。你不喜欢给定的序列,希望将其变为更符合你心意的新序列 B。因此,你被允许执行以下四种操作:
- 你可以在序列的任意位置插入一个任意标签的球;
- 你可以从任意位置删除(移除)一个球;
- 你可以将任意一个球替换为另一个任意球;
- 你可以交换两个相邻的球。
现在,老师对每种操作施加了时间限制,即每种操作只能在特定时间内完成:第一种操作耗时 ti,第二种操作耗时 td,第三种操作耗时 tr,第四种操作耗时 te。此外,已知满足约束 2⋅te≥ti+td。
求将序列 A 转换为序列 B 所需的最少时间。
输入格式
The first line contains four space-separated integers t__i, t__d, t__r, t__e (0 < t__i, t__d, t__r, t__e ≤ 100). The following two lines contain sequences A and B on separate lines. The length of each line is between 1 and 4000 characters inclusive.
第一行包含四个以空格分隔的整数 ti、td、tr、te(0<ti,td,tr,te≤100)。接下来的两行分别包含序列 A 和 B。每行的长度在 1 到 4000 个字符之间(含端点)。
输出格式
Print a single integer representing minimum time to convert A into B.
输出一个整数,表示将 A 转换为 B 所需的最少时间。
输入输出样例
输入#1
1 1 1 1 youshouldnot thoushaltnot
输出#1
5
输入#2
2 4 10 3 ab ba
输出#2
3
输入#3
1 10 20 30 a za
输出#3
1
说明/提示
In the second sample, you could delete the ball labeled 'a' from the first position and then insert another 'a' at the new second position with total time 6. However exchanging the balls give total time 3.
在第二个样例中,你可以删除第一个位置上标记为 'a' 的球,然后在新的第二个位置插入另一个 'a',总耗时为 6。然而,交换这两个球的总耗时仅为 3。
输入解题思路,AI测评打分。不知道怎么写?