Under construction

Still being built. Things may change

Binary String

Time limit4sMemory limit2048 MB

Summary
For each k, count the 1s in T_k, where each ? copies the character k positions before it and leading ? positions become 0.
Level

Medium6 of 10

Topics
Bit manipulation, String, Brute force
Solved
No attempts yet

Problem

You are given a string s1s2…sns_1 s_2 \ldots s_n of length nn. Each character is one of 0, 1, or ?.

For every k∈[1,n]k \in [1, n], define the string Tk=t1t2…tnT_k = t_1 t_2 \ldots t_n as follows. For each 1≤i≤n1 \le i \le n:

  • If si≠s_i \ne ?, then ti=sit_i = s_i.
  • Otherwise, if i≤ki \le k, then ti=t_i = 0.
  • Otherwise, ti=ti−kt_i = t_{i-k}. You can compute ti−kt_{i-k} recursively to obtain tit_i.

The character set of TkT_k is 01. For every k∈[1,n]k \in [1, n], count the number of 1 characters in TkT_k.

Input

The first line contains an integer nn (1≤n≤1051 \le n \le 10^5), the length of the string.

The second line contains the string s1s2…sns_1 s_2 \ldots s_n of length nn. Each character is one of 0, 1, or ?.

Output

Print nn lines. The kk-th line contains the number of 1 characters in TkT_k.

Examples1

  1. Example 1

    Input
    5
    10?1?
    
    Expected output
    3
    4
    2
    3
    2