CF978B.File Name

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed.

Determine the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. Print 0 if the file name does not initially contain a forbidden substring "xxx".

You can delete characters in arbitrary positions (not necessarily consecutive). If you delete a character, then the length of a string is reduced by 11. For example, if you delete the character in the position 22 from the string "exxxii", then the resulting string is "exxii".

你不能直接上传该文件并发送。当 Polycarp 尝试在社交网络 “Codehorses” 中发送一个文件时,他遇到了一个意外问题:如果文件名中包含连续三个或更多个小写拉丁字母 x(即子串 "xxx"),系统便会认为该文件内容与社交网络的主题不符;此时文件无法发送,并会显示一条错误信息。

请确定:为使文件名中不再包含子串 "xxx",至少需要从文件名中删除多少个字符?若文件名初始就不含禁止的子串 "xxx",则输出 0。

你可以删除任意位置上的字符(不一定要连续)。每次删除一个字符,字符串长度减少 11。例如,若从字符串 "exxxii" 的第 22 个位置(按 1 开始计数)删除字符,则得到的新字符串为 "exxii"。

输入格式

The first line contains integer nn (3≤n≤100)(3 \le n \le 100) — the length of the file name.

The second line contains a string of length nn consisting of lowercase Latin letters only — the file name.

第一行包含一个整数 nn(3≤n≤1003 \le n \le 100)—— 文件名的长度。

第二行包含一个长度为 nn 的字符串,仅由小写拉丁字母组成—— 文件名。

输出格式

Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0.

输出从文件名中删除的最少字符数,使得删除后文件名中不包含子串 “xxx”。如果文件名初始就不包含被禁止的子串 “xxx”,则输出 0。

输入输出样例

  • 输入#1

    6
    xxxiii

    输出#1

    1
  • 输入#2

    5
    xxoxx

    输出#2

    0
  • 输入#3

    10
    xxxxxxxxxx

    输出#3

    8

说明/提示

In the first example Polycarp tried to send a file with name contains number 3333, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters.

在第一个例子中,Polycarp 尝试发送一个文件,其文件名中包含用罗马数字表示的数字 3333。但他不能直接发送该文件,因为其文件名中连续包含了三个字母 “x”。为了发送该文件,他需要删除其中任意一个 “x”。

输入解题思路,AI测评打分。不知道怎么写?

首页