C - Hurdle Parsing Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

いろはちゃんは長さ N ( N \ge 1 ) の正整数列 A=(A_1,A_2,\dots,A_N) を持っています。
いろはちゃんは A を使って、次のように文字列 S を生成しました。

  • S= | から始める。
  • i=1,2,\dots,N の順に、次の操作を行う。
    • S の末尾に -A_i 個追加する。
    • その後、 S の末尾に |1 個追加する。

生成された文字列 S が与えられるので、正整数列 A を復元してください。

制約

  • S は問題文中の方法で生成された長さ 3 以上 100 以下の文字列
  • A は長さ 1 以上の正整数列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

答えを以下の形式で、 1 行に空白区切りで出力せよ。

A_1 A_2 \dots A_N

入力例 1

|---|-|----|-|-----|

出力例 1

3 1 4 1 5

S= |---|-|----|-|-----| が生成されるような A(3,1,4,1,5) です。


入力例 2

|----------|

出力例 2

10

入力例 3

|-|-|-|------|

出力例 3

1 1 1 6

Score : 200 points

Problem Statement

Iroha has a sequence of positive integers A = (A_1, A_2, \dots, A_N) of length N (N \ge 1).
She generated a string S using A as follows:

  • Start with S = |.
  • For i = 1, 2, \dots, N, perform the following operations in order:
    • Append A_i copies of - to the end of S.
    • Then, append one | to the end of S.

Given the generated string S, reconstruct the sequence A.

Constraints

  • S is a string of length between 3 and 100, inclusive, generated by the method in the problem statement.
  • A is a sequence of positive integers of length at least 1.

Input

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

S

Output

Print the answer in the following format, with elements separated by spaces in a single line:

A_1 A_2 \dots A_N

Sample Input 1

|---|-|----|-|-----|

Sample Output 1

3 1 4 1 5

S = |---|-|----|-|-----| is generated by A = (3, 1, 4, 1, 5).


Sample Input 2

|----------|

Sample Output 2

10

Sample Input 3

|-|-|-|------|

Sample Output 3

1 1 1 6