A11439 | Anti-Palindromize
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A string $a$ of length $m$ is called antipalindromic iff $m$ is even, and for each $i$ ( $1<=i<=m$ ) $a_{i}≠a_{m-i+1}$ .
Ivan has a string $s$ consisting of $n$ lowercase Latin letters; $n$ is even. He wants to form some string $t$ that will be an antipalindromic permutation of $s$ . Also Ivan has denoted the beauty of index $i$ as $b_{i}$ , and the beauty of $t$ as the sum of $b_{i}$ among all indices $i$ such that $s_{i}=t_{i}$ .
Help Ivan to determine maximum possible beauty of $t$ he can get.
Ivan has a string $s$ consisting of $n$ lowercase Latin letters; $n$ is even. He wants to form some string $t$ that will be an antipalindromic permutation of $s$ . Also Ivan has denoted the beauty of index $i$ as $b_{i}$ , and the beauty of $t$ as the sum of $b_{i}$ among all indices $i$ such that $s_{i}=t_{i}$ .
Help Ivan to determine maximum possible beauty of $t$ he can get.
输入格式
The first line contains one integer $n$ ( $2<=n<=100$ , $n$ is even) — the number of characters in $s$ .
The second line contains the string $s$ itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains $n$ integer numbers $b_{1}$ , $b_{2}$ , ..., $b_{n}$ ( $1<=b_{i}<=100$ ), where $b_{i}$ is the beauty of index $i$ .
The second line contains the string $s$ itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains $n$ integer numbers $b_{1}$ , $b_{2}$ , ..., $b_{n}$ ( $1<=b_{i}<=100$ ), where $b_{i}$ is the beauty of index $i$ .
输出格式
Print one number — the maximum possible beauty of $t$ .
输入输出样例
输入 #1
8 abacabac 1 1 1 1 1 1 1 1
输出 #1
8
输入 #2
8 abaccaba 1 2 3 4 5 6 7 8
输出 #2
26
输入 #3
8 abacabca 1 2 3 4 4 3 2 1
输出 #3
17
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted