CF613C.Necklace
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remaining after this cut is a palindrome (reads the same forward and backward).

Ivan has beads of n colors. He wants to make a necklace, such that it's beautiful relative to as many cuts as possible. He certainly wants to use all the beads. Help him to make the most beautiful necklace.
伊万想为他心爱的女孩制作一条项链作为礼物。项链是由不同颜色的珠子构成的一个环状序列。伊万称:若在某两个相邻珠子之间进行切割,剩余的珠子链构成一个回文串(即正读与反读完全相同),则该项链相对于该切割点是“美丽的”。

伊万有 n 种颜色的珠子。他希望制作一条项链,使其相对于尽可能多的切割点是美丽的。他当然希望使用全部珠子。请帮助他制作出最美丽的项链。
输入格式
The first line of the input contains a single number n (1 ≤ n ≤ 26) — the number of colors of beads. The second line contains after n positive integers a__i — the quantity of beads of i-th color. It is guaranteed that the sum of a__i is at least 2 and does not exceed 100 000.
输入的第一行包含一个整数 n(1≤n≤26)—— 表示珠子的颜色种数。
第二行包含 n 个正整数 ai —— 表示第 i 种颜色的珠子数量。
保证所有 ai 的总和至少为 2,且不超过 100000。
输出格式
In the first line print a single number — the maximum number of beautiful cuts that a necklace composed from given beads may have. In the second line print any example of such necklace.
Each color of the beads should be represented by the corresponding lowercase English letter (starting with a). As the necklace is cyclic, print it starting from any point.
第一行输出一个整数——由给定珠子组成的项链所能拥有的最多“优美切割”数量。
第二行输出任意一种满足该最大数量的项链示例。
每种颜色的珠子用对应的小写英文字母表示(从 a 开始)。由于项链是环状的,可从任意位置开始输出。
输入输出样例
输入#1
3 4 2 1
输出#1
1 abacaba
输入#2
1 4
输出#2
4 aaaa
输入#3
2 1 1
输出#3
0 ab
说明/提示
In the first sample a necklace can have at most one beautiful cut. The example of such a necklace is shown on the picture.
In the second sample there is only one way to compose a necklace.
在第一个样例中,一条项链最多只能有一个优美的切割点。图中展示了一条具有该性质的项链示例。
在第二个样例中,仅有一种方式可以组成一条项链。
输入解题思路,AI测评打分。不知道怎么写?