AT_abc469_c.Cantrip

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a string SS of length NN consisting of o and x.
NN bags are arranged in a row, and each bag contains one sweet.
On the ii-th bag, "hit" is written if the ii-th character of SS is o, and "miss" is written if it is x.
For each k=1,2,…,Nk=1,2,\dots,N, solve the following problem.

Takahashi receives the first kk bags from the front of the row, eats the sweets inside them, and keeps the bags.
Then, he repeats the following action as many times as possible.

  • He discards one bag marked "hit" that he is holding, receives the bag at the front of the row, eats the sweet inside it, and keeps that bag. This action can only be performed when there is still a bag remaining in the row and he is holding a bag marked "hit".

Find the number of sweets he can eat.
Note that when he receives a bag, that bag is removed from the row.

给你一个长度为 NN 的字符串 SS,它仅由字符 o 和 x 组成。
有 NN 个袋子排成一排,每个袋子里装有一颗糖果。
第 ii 个袋子上写着“hit”,当且仅当 SS 的第 ii 个字符为 o;写着“miss”,当且仅当该字符为 x。
对每个 k=1,2,…,Nk=1,2,\dots,N,求解以下问题:

高桥从队列前端依次接收前 kk 个袋子,吃掉其中的糖果,并保留这些袋子。
然后,他尽可能多地重复执行以下操作:

  • 丢弃一个他手中标记为“hit”的袋子,再从队列前端接收一个袋子,吃掉其中的糖果,并保留该袋子。该操作仅在队列中仍有剩余袋子、且他手中持有至少一个标记为“hit”的袋子时才可执行。

求他总共能吃到多少颗糖果。
注意:当他接收一个袋子时,该袋子即从队列中移除。

输入格式

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

NN
SS

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

NN
SS

输出格式

Output a total of NN lines.
The ll-th line should contain the answer for k=lk=l.

共输出 NN 行。
第 ll 行应包含 k=lk=l 时的答案。

输入输出样例

  • 输入#1

    5
    oxoxo

    输出#1

    2
    4
    5
    5
    5
  • 输入#2

    3
    ooo

    输出#2

    3
    3
    3
  • 输入#3

    1
    x

    输出#3

    1

说明/提示

Sample 1 Explanation:
For k=1k=1, the bag he receives is marked "hit". He discards it, and the bag he then receives is marked "miss", so he cannot perform any further actions.

Constraints

  • 1≤N≤8×1051 \leq N \leq 8 \times 10^5
  • NN is an integer.
  • SS is a string of length NN consisting of o and x.

样例 1 解释:
当 k=1k=1 时,他收到的袋子标记为 “hit”。他将其丢弃,随后收到的袋子标记为 “miss”,因此他无法再执行任何操作。

约束条件

  • 1≤N≤8×1051 \leq N \leq 8 \times 10^5
  • NN 是一个整数。
  • SS 是一个长度为 NN 的字符串,仅由字符 o 和 x 组成。

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

首页