{"problem":{"name":"C. Is This a Zebra?","description":{"content":"A camera you have accidentally left in a desert has taken an interesting photo. The photo has a resolution of _n_ pixels width, and each column of this photo is all white or all black. Thus, we can re","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF953C"},"statements":[{"statement_type":"Markdown","content":"A camera you have accidentally left in a desert has taken an interesting photo. The photo has a resolution of _n_ pixels width, and each column of this photo is all white or all black. Thus, we can represent the photo as a sequence of _n_ zeros and ones, where 0 means that the corresponding column is all white, and 1 means that the corresponding column is black.\n\nYou think that this photo can contain a zebra. In this case the whole photo should consist of several (possibly, only one) alternating black and white stripes of equal width. For example, the photo \\[0, 0, 0, 1, 1, 1, 0, 0, 0\\] can be a photo of zebra, while the photo \\[0, 0, 0, 1, 1, 1, 1\\] can not, because the width of the black stripe is 3, while the width of the white stripe is 4. Can the given photo be a photo of zebra or not?\n\n## Input\n\nThe first line contains a single integer _n_ (1 ≤ _n_ ≤ 100 000) — the width of the photo.\n\nThe second line contains a sequence of integers _a_1, _a_2, ..., _a__n_ (0 ≤ _a__i_ ≤ 1) — the description of the photo. If _a__i_ is zero, the _i_\\-th column is all black. If _a__i_ is one, then the _i_\\-th column is all white.\n\n## Output\n\nIf the photo can be a photo of zebra, print \"_YES_\" (without quotes). Otherwise, print \"_NO_\".\n\nYou can print each letter in any case (upper or lower).\n\n[samples]\n\n## Note\n\nThe first two examples are described in the statements.\n\nIn the third example all pixels are white, so the photo can be a photo of zebra.\n\nIn the fourth example the width of the first stripe is equal to three (white color), the width of the second stripe is equal to three (black), and the width of the third stripe is equal to two (white). Thus, not all stripes have equal length, so this photo is not a photo of zebra.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"你不小心将一台相机留在了沙漠中，它拍下了一张有趣的照片。这张照片的分辨率为 #cf_span[n] 像素宽，且每一列要么全白，要么全黑。因此，我们可以用一个包含 #cf_span[n] 个 0 和 1 的序列来表示这张照片，其中 #cf_span[0] 表示对应列全白，#cf_span[1] 表示对应列全黑。\n\n你认为这张照片可能是一只斑马的照片。在这种情况下，整张照片应由若干个（可能只有一个）交替的黑白条纹组成，且每个条纹宽度相等。例如，照片 #cf_span[[0, 0, 0, 1, 1, 1, 0, 0, 0]] 可以是一张斑马的照片，而照片 #cf_span[[0, 0, 0, 1, 1, 1, 1]] 则不行，因为黑色条纹的宽度为 #cf_span[3]，而白色条纹的宽度为 #cf_span[4]。给定的照片是否可能是一张斑马的照片？\n\n第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100 000]) —— 照片的宽度。\n\n第二行包含一个整数序列 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 1]) —— 照片的描述。如果 #cf_span[ai] 为 0，则第 #cf_span[i] 列全黑；如果 #cf_span[ai] 为 1，则第 #cf_span[i] 列全白。\n\n如果照片可能是斑马的照片，请输出 \"_YES_\"（不含引号）；否则，输出 \"_NO_\"。\n\n你可以以任意大小写形式输出每个字母。\n\n前两个例子已在题面中描述。\n\n在第三个例子中，所有像素均为白色，因此这张照片可以是一张斑马的照片。\n\n在第四个例子中，第一个条纹的宽度为三（白色），第二个条纹的宽度为三（黑色），第三个条纹的宽度为二（白色）。因此，并非所有条纹长度相等，这张照片不是斑马的照片。\n\n## Input\n\n第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100 000]) —— 照片的宽度。第二行包含一个整数序列 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 1]) —— 照片的描述。如果 #cf_span[ai] 为 0，则第 #cf_span[i] 列全黑；如果 #cf_span[ai] 为 1，则第 #cf_span[i] 列全白。\n\n## Output\n\n如果照片可能是斑马的照片，请输出 \"_YES_\"（不含引号）；否则，输出 \"_NO_\"。你可以以任意大小写形式输出每个字母。\n\n[samples]\n\n## Note\n\n前两个例子已在题面中描述。在第三个例子中，所有像素均为白色，因此这张照片可以是一张斑马的照片。在第四个例子中，第一个条纹的宽度为三（白色），第二个条纹的宽度为三（黑色），第三个条纹的宽度为二（白色）。因此，并非所有条纹长度相等，这张照片不是斑马的照片。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the width of the photo.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence where $ a_i \\in \\{0, 1\\} $, representing the color of column $ i $:  \n- $ a_i = 0 $: white  \n- $ a_i = 1 $: black  \n\n**Constraints**  \n$ 1 \\leq n \\leq 100{,}000 $  \n\n**Objective**  \nDetermine whether $ A $ can be partitioned into contiguous stripes of equal width $ w \\geq 1 $, alternating between 0 and 1, starting with either 0 or 1.  \n\nThat is, there exists $ w \\in \\mathbb{Z}^+ $ and $ k \\in \\mathbb{Z}^+ $ such that:  \n- $ n = k \\cdot w $,  \n- For each $ j \\in \\{0, 1, \\dots, k-1\\} $, the segment $ A[jw+1 : (j+1)w] $ is constant,  \n- The constant value alternates between consecutive segments: $ \\text{value}(j+1) \\neq \\text{value}(j) $ for all $ j \\in \\{0, \\dots, k-2\\} $.  \n\nOutput \"YES\" if such $ w $ exists; otherwise, output \"NO\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF953C","tags":[],"sample_group":[["9\n0 0 0 1 1 1 0 0 0","YES"],["7\n0 0 0 1 1 1 1","NO"],["5\n1 1 1 1 1","YES"],["8\n1 1 1 0 0 0 1 1","NO"],["9\n1 1 0 1 1 0 1 1 0","NO"]],"created_at":"2026-03-03 11:00:39"}}