-->
当前位置:首页 > 题库

PROGRAMMING:Happy and happy

Luz5年前 (2021-05-10)题库423
Although he didn't know what it meant, he still took $$s $$to install $$B $$with $$bear2 $. Finally, he made $$bear2 $$anxious.
$$bear2 $$wants to destroy his favorite, but $$DH $$encrypts his mobile phone. If $$bear2 $$wants to delete any letter, it will pay a certain price, which is related to the left and right two adjacent letters of the letter. The $$I $$letter will protect the $$J $$letter, and its ability value is $$W_{ i,j}$$ 。
The first letter is $$a $$, $$W_{ 1,2} $$indicates that the ability of the letter $$a $$to protect the letter $$B $$is $$W_{ 1,2}$$ 。
Let the cost of deleting the character $$C $$in the $$I $$position be $$W_{ l,c}\ +\ W_{ r. C} $$($$l, R $$denote the characters that have not been deleted from the left and right adjacent * * of bit $$I $$), if the left side of bit $$I $$is empty, $$W_{ l. I} $$is zero, the right side is the same.
Can you help $$bear 2 $$find the minimum cost?
###Input format:
The first line gives the number of sample groups $$t (1 < = T < = 10)$$
In each group of samples, from line $$1 to line $$5, each line gives $$5 non negative integers.
Nonnegative integer $$W in line $$I $, column $$J $_{ i,j}(0<=W_{ i. J} < = 500) $$indicates the ability value of the $$I $$letter to protect the $$J $$letter.
Line $$6 $$gives a positive integer $$n (1 < = n < = 200) $, indicating the length of the string $$s $
Line $$7 $$gives the string $$s$$
###Output format:
Output the minimum cost in one line
###Input example:
Here is a set of inputs. For example:
```in
one
32 40 17 40 35
13 19 7 3 5
11 41 42 6 17
47 21 42 35 23
20 45 36 16 42
five
addbd
```
###Output example:
The corresponding output is given here. For example:
```out
eighty-eight
```
###Tips:
40% of data $$n < = 20$$
100% of the data $$n < = 200 $$< br > < br > < br > < br > < br > is available


answer:If there is no answer, please comment