{"raw_statement":[{"iden":"statement","content":"You are given the array of integer numbers _a_0, _a_1, ..., _a__n_ - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array."},{"iden":"input","content":"The first line contains integer _n_ (1 ≤ _n_ ≤ 2·105) — length of the array _a_. The second line contains integer elements of the array separated by single spaces ( - 109 ≤ _a__i_ ≤ 109)."},{"iden":"output","content":"Print the sequence _d_0, _d_1, ..., _d__n_ - 1, where _d__i_ is the difference of indices between _i_ and nearest _j_ such that _a__j_ = 0. It is possible that _i_ = _j_."},{"iden":"examples","content":"Input\n\n9\n2 1 0 3 0 0 3 2 4\n\nOutput\n\n2 1 0 1 0 0 1 2 3 \n\nInput\n\n5\n0 1 2 3 4\n\nOutput\n\n0 1 2 3 4 \n\nInput\n\n7\n5 6 0 1 -2 3 4\n\nOutput\n\n2 1 0 1 2 3 4"}],"translated_statement":[{"iden":"statement","content":"给定一个整数数组 #cf_span[a0, a1, ..., an - 1]。对于每个元素，求其到最近的零元素（值为零的元素）的距离。给定数组中至少有一个零元素。\n\n第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2·105]) —— 数组 #cf_span[a] 的长度。第二行包含用空格分隔的数组元素 (#cf_span[ - 109 ≤ ai ≤ 109])。\n\n请输出序列 #cf_span[d0, d1, ..., dn - 1]，其中 #cf_span[di] 是下标 #cf_span[i] 与最近的下标 #cf_span[j] 之间的差值，满足 #cf_span[aj = 0]。允许 #cf_span[i = j]。"},{"iden":"input","content":"第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2·105]) —— 数组 #cf_span[a] 的长度。第二行包含用空格分隔的数组元素 (#cf_span[ - 109 ≤ ai ≤ 109])。"},{"iden":"output","content":"请输出序列 #cf_span[d0, d1, ..., dn - 1]，其中 #cf_span[di] 是下标 #cf_span[i] 与最近的下标 #cf_span[j] 之间的差值，满足 #cf_span[aj = 0]。允许 #cf_span[i = j]。"},{"iden":"examples","content":"输入92 1 0 3 0 0 3 2 4输出2 1 0 1 0 0 1 2 3 输入50 1 2 3 4输出0 1 2 3 4 输入75 6 0 1 -2 3 4输出2 1 0 1 2 3 4 "}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ denote the length of the array.  \nLet $ A = (a_0, a_1, \\dots, a_{n-1}) $ be a sequence of integers where $ \\exists\\, j \\in \\{0, \\dots, n-1\\} $ such that $ a_j = 0 $.  \n\nLet $ Z = \\{ j \\in \\{0, \\dots, n-1\\} \\mid a_j = 0 \\} $ be the set of indices where the element is zero.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 2 \\cdot 10^5 $  \n2. $ -10^9 \\leq a_i \\leq 10^9 $ for all $ i \\in \\{0, \\dots, n-1\\} $  \n3. $ Z \\neq \\emptyset $\n\n**Objective**  \nFor each $ i \\in \\{0, \\dots, n-1\\} $, compute:  \n$$ d_i = \\min_{j \\in Z} |i - j| $$  \nOutput the sequence $ (d_0, d_1, \\dots, d_{n-1}) $.","simple_statement":null,"has_page_source":false}