小戏法AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given a string $S$ of length $N$ consisting of o and x.
$N$ bags are arranged in a row, and each bag contains one sweet.
On the $i$-th bag, "hit" is written if the $i$-th character of $S$ is o, and "miss" is written if it is x.
For each $k=1,2,\dots,N$, solve the following problem.
Takahashi receives the first
$k$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.
给定一个由 o 和 x 组成的长度为 $N$ 的字符串 $S$。
有 $N$ 个袋子排成一列,每个袋子中装有一颗糖果。
如果 $S$ 的第 $i$ 个字符是 o,则第 $i$ 个袋子上写着“命中”;如果是 x,则写着“未命中”。
对于每个 $k=1,2,\dots,N$,请解决以下问题。
AI (CI翻译)高桥从队列前端拿走前
$k$个袋子,吃掉其中的糖果,并保留这些袋子。 然后,他尽可能多次地重复以下操作。
- 丢弃一个他持有的、标有“命中”的袋子,从队列前端拿走一个袋子,吃掉其中的糖果,并保留这个袋子。只有当队列中仍有袋子,且他持有至少一个标有“命中”的袋子时,才能进行此操作。
求他能够吃掉的糖果数量。
注意,当他拿走一个袋子时,该袋子会从队列中移除。
Constraints
约束条件
AI (CI翻译)$1 \leq N \leq 8 \times 10^5$$N$is an integer.$S$is a string of length$N$consisting ofoandx.
$1 \leq N \leq 8 \times 10^5$$N$是整数。$S$是一个由o和x组成的长度为$N$的字符串。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N
S
N
SAI (CI翻译)
Output
输出格式
AI (CI翻译)Output a total of $N$ lines.
The $l$-th line should contain the answer for $k=l$.
输出共 $N$ 行。
第 $l$ 行应包含 $k=l$ 时的答案。AI (CI翻译)
样例
5
oxoxo
2
4
5
5
5
3
ooo
3
3
3
1
x
1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。