CF1040A Palindrome Dance

题目描述

### 题目大意 给你一个序列,里面的元素只能是 $0,1$ 或 $2$,$2$ 可以通过代价换成 $1$ 或者 $0$,问形成**仅包含 $0,1$** 的回文串的最小代价。

输入格式

第一行 $3$ 个整数 $n,a,b$,分别代表了序列长度,换成 $0$ 的代价,换成 $1$ 的代价。 第二行 $n$ 个整数,表示序列。

输出格式

如果能构成回文串,输出最小代价,否则输出 $-1$。

说明/提示

In the first sample, the cheapest way to obtain palindromic colors is to buy a black suit for the third from left dancer and a white suit for the rightmost dancer. In the second sample, the leftmost dancer's suit already differs from the rightmost dancer's suit so there is no way to obtain the desired coloring. In the third sample, all suits are already bought and their colors form a palindrome.