{"problem":{"name":"B. Distances to Zero","description":{"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","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF803B"},"statements":[{"statement_type":"Markdown","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.\n\n## Input\n\nThe 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).\n\n## Output\n\nPrint 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_.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","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]。\n\n## Input\n\n第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2·105]) —— 数组 #cf_span[a] 的长度。第二行包含用空格分隔的数组元素 (#cf_span[ - 109 ≤ ai ≤ 109])。\n\n## Output\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]。\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**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}) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF803B","tags":["constructive algorithms"],"sample_group":[["9\n2 1 0 3 0 0 3 2 4","2 1 0 1 0 0 1 2 3"],["5\n0 1 2 3 4","0 1 2 3 4"],["7\n5 6 0 1 -2 3 4","2 1 0 1 2 3 4"]],"created_at":"2026-03-03 11:00:39"}}