#abc264d. D - "redocta".swap(i,i+1)
D - "redocta".swap(i,i+1)
Score : points
问题描述
你将获得一个字符串 ,它是 atcoder
的一个排列。
在该字符串 上,你需要执行以下操作零次或多次:
- 选择 中的两个相邻字符并交换它们。
找出使 等于 atcoder
所需的最少操作次数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string that is a permutation of atcoder
.
On this string , you will perform the following operation or more times:
- Choose two adjacent characters of and swap them.
Find the minimum number of operations required to make equal atcoder
.
Constraints
- is a string that is a permutation of
atcoder
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
catredo
Sample Output 1
8
You can make equal atcoder
in operations as follows:
catredo
[ac]tredo
actre[od]
actr[oe]d
actro[de]
act[or]de
acto[dr]e
a[tc]odre
atcod[er]
This is the minimum number of operations achievable.
Sample Input 2
atcoder
Sample Output 2
0
In this case, the string is already atcoder
.
Sample Input 3
redocta
Sample Output 3
21
update @ 2024/3/10 11:09:23