No.2773 Wake up Record 1
タグ : / 解いたユーザー数 177
作問者 :
amentorimaru
👑 Story
Yu-san has been having trouble sleeping lately and keeps waking up many times during the night.
So Yu-san decided to find out when these awakenings happen, in order to improve the quality of sleep.
To that end, Yu-san bought a sleep-recording robot and had it record Yu-san's sleep state.
Your job is to find, on Yu-san's behalf, all the times at which Yu-san woke up.
"I hope this will let me sleep properly at night..."
Problem Statement
Yu-san decided to have a robot keep a sleep record.
The robot measures Yu-san's state from time $1$ to time $N$ and records the sleep record as a string $S$ of $N$ characters.
$S$ consists only of o and x. If the $i$-th character is o, it means that Yu-san is awake at time $i$; if it is x, it means that Yu-san is asleep.
Assume that Yu-san was asleep until just before time $1$. Among the integers $k$ satisfying $2 \leq k \leq N$, output all those such that Yu-san is asleep at time $k-1$ and awake at time $k$, in ascending order.
Input
$N$ $S$
Constraints
- $1 \leqq N \leqq 10^5$
- $|S| = N$
- $N$ is an integer
- $S$ is a string consisting only of the lowercase English letters
oandx - The $1$-st character of $S$ is
x
Output
Output $2$ lines.
On the $1$-st line, output the number of $k$ satisfying the condition.
On the $2$-nd line, output all $k$ satisfying the condition in ascending order, separated by spaces.
Sample
Sample 1
Input
8 xxoooxxo
Output
2 3 8
The values of $k$ satisfying the condition are $3$ and $8$, which makes $2$ values.
Therefore, output2, the number of such $k$, on the $1$-st line, and 3 8, the values of $k$ satisfying the condition, on the $2$-nd line.
Sample 2
Input
1 x
Output
0
The number of $k$ satisfying the condition may be $0$.
Sample 3
Input
19 xooxoooxxxxoooxooox
Output
4 2 5 12 16
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。