7064.Bit Substrings

Time Limit: 1s Memory Limit: 512MB

You are given a bit string of length $n$ . Your task is to calculate for each $k$ between $0 \ldots n$ the number of non-empty substrings that contain exactly $k$ ones.

For example, if the string is 101, there are:

  • 1 substring that contains 0 ones: 0
  • 4 substrings that contain 1 one: 01, 1, 1, 10
  • 1 substring that contains 2 ones: 101
  • 0 substrings that contain 3 ones

Input Format(From the terminal/stdin)

The only input line contains a binary string of length $n$ .

  • $1 \le n \le 2 \cdot 10^5$

Output Format(To the terminal/stdout)

Print $n+1$ values as specified above.

Sample Input

Copy
101
   \n

Sample Output

Copy
1 4 1 0
 · · · \n
Source: CSES, Additional Problems II, 2115

Submit

请先 登录

© 2025 FAQs