AT_abc469_b.Isolated Seats

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a string SS of length NN consisting of o and x.
NN chairs are arranged in a row from left to right. If the ii-th character of SS is o, a person is sitting in the ii-th chair from the left; if it is x, no person is sitting there.
Find the number of chairs that satisfy all of the following conditions.

  • No person is sitting in it.
  • There is no chair to its left, or no person is sitting in the chair to its left.
  • There is no chair to its right, or no person is sitting in the chair to its right.

给你一个长度为 NN 的字符串 SS,其中只包含字符 o 和 x。
从左到右依次排列着 NN 把椅子。若 SS 的第 ii 个字符为 o,则从左数第 ii 把椅子上坐着一个人;若为 x,则该椅子上无人就座。
求满足以下所有条件的椅子的数量:

  • 该椅子上无人就座;
  • 该椅子左侧没有椅子,或者其左侧的椅子上无人就座;
  • 该椅子右侧没有椅子,或者其右侧的椅子上无人就座。

输入格式

The input is given from Standard Input in the following format:

NN
SS

输入从标准输入中按以下格式给出:

NN
SS

输出格式

Output the answer in one line.

一行输出答案。

输入输出样例

  • 输入#1

    8
    xxoxxxox

    输出#1

    2
  • 输入#2

    5
    ooooo

    输出#2

    0
  • 输入#3

    1
    x

    输出#3

    1

说明/提示

Sample 1 Explanation:
Only the first and fifth chairs from the left satisfy the conditions.

Constraints

  • 1≤N≤1001 \leq N \leq 100
  • NN is an integer.
  • SS is a string of length NN consisting of o and x.

样例 1 解释:
仅从左数第 1 张和第 5 张椅子满足条件。

限制条件

  • 1≤N≤1001 \leq N \leq 100
  • NN 是一个整数。
  • SS 是一个长度为 NN 的字符串,仅由字符 o 和 x 组成。

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

首页