#AT2272. D - "redocta".swap(i,i+1)
D - "redocta".swap(i,i+1)
当前没有测试数据。
D - "redocta".swap(i,i+1)
分数:400点
问题描述
给定一个字符串 $S$,该字符串是atcoder
的一个排列。
在字符串 $S$ 上,你可以进行以下操作 $0$ 次或多次:
- 选择 $S$ 中相邻的两个字符并交换。
找出使 $S$ 变为atcoder
的最小操作次数。
限制条件
- $S$ 是一个排列
atcoder
的字符串
输入
从标准输入中按以下格式给出输入:
输出
以整数形式输出答案。
catredo
8
你可以通过以下 $8$ 次操作使 $S$ 变为atcoder
:
catredo
$\rightarrow$ [ac]tredo
$\rightarrow$ actre[od]
$\rightarrow$ actr[oe]d
$\rightarrow$ actro[de]
$\rightarrow$ act[or]de
$\rightarrow$ acto[dr]e
$\rightarrow$ a[tc]odre
$\rightarrow$ atcod[er]
这是可行的最小操作次数。
atcoder
0
在这种情况下,字符串 $S$ 已经是atcoder
。
redocta
21