#P6758. [BalticOI 2013] Vim
[BalticOI 2013] Vim
Problem Description
Given a string of length , Victor’s goal is to delete all e characters in it, without deleting any other character. At the beginning, the cursor is at the first character.
Victor uses Vim to solve this problem.
However, Victor is not familiar with Vim. He only knows the following three commands:
x: Delete the character under the cursor. The cursor position does not change. This command cannot be used when the cursor is at the last character.h: Move the cursor one position to the left. If the cursor is at the first position, it does not move.f: Followed by a character , it moves the cursor to the first character to its right, wheree.
Compute the minimum number of keystrokes needed to delete all e characters, without deleting any other character.
Input Format
The first line contains an integer .
The next line contains a string .
Output Format
Output a single integer, the minimum number of keystrokes needed to delete all e characters, without deleting any other character.
35
chefeddiefedjeffeachbigagedegghehad
36
Hint
Sample Explanation
fdhxhhxffhxfahxhhhxhhhxfdhxfghxfahhx is an optimal solution.
Constraints
- For points, it is guaranteed that .
- For another points, it is guaranteed that .
- For of the testdata, it is guaranteed that ,
aj,e.
Translator’s note: I really cannot figure out how it was set up, so I used Luogu’s default settings.
Notes
This problem is translated from Baltic Olympiad in Informatics 2013 Day 2 T3 Vim.
Translated by ChatGPT 5