AT_abc469_b.Isolated Seats
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string S of length N consisting of o and x.
N chairs are arranged in a row from left to right. If the i-th character of S is o, a person is sitting in the i-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.
给你一个长度为 N 的字符串 S,其中只包含字符 o 和 x。
从左到右依次排列着 N 把椅子。若 S 的第 i 个字符为 o,则从左数第 i 把椅子上坐着一个人;若为 x,则该椅子上无人就座。
求满足以下所有条件的椅子的数量:
- 该椅子上无人就座;
- 该椅子左侧没有椅子,或者其左侧的椅子上无人就座;
- 该椅子右侧没有椅子,或者其右侧的椅子上无人就座。
输入格式
The input is given from Standard Input in the following format:
N
S
输入从标准输入中按以下格式给出:
N
S
输出格式
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≤100
- N is an integer.
- S is a string of length N consisting of
oandx.
样例 1 解释:
仅从左数第 1 张和第 5 张椅子满足条件。
限制条件
- 1≤N≤100
- N 是一个整数。
- S 是一个长度为 N 的字符串,仅由字符
o和x组成。
输入解题思路,AI测评打分。不知道怎么写?