304628: CF883H. Palindromic Cut
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Palindromic Cut
题意翻译
## 题目描述 Kolya有一个长度为 $n$ 的字符串 $s$ ,其中含有大小写英文字母和数字。 他想要重新编排 $s$ 中字符的顺序并将它切割为最少个子串,使得每个子串都为回文串且所有子串长度相等。回文串指的是从前往后读和从后往前读相同 的字符串,例如`madam`或`racecar`。 你的任务是帮助Kolya计算出所需切割出 $s$ 子串总数的最小值。 ## 输入格式 第一行包括一个整数 $n(1 \leq n \leq 4⋅10^5)$。 第二行为长度为 $n$ 的字符串 $s$。 ## 输出格式 第一行输出一个整数 $k$ ,表示需要切割出的最少子串数。 第二行输出切割后的 $k$ 个字符串,每两个之间用一个空格隔开。你可以以任意顺序输出这些等长的字符串。 由 @Segment_Tree 提供翻译,Reformed by @devdede。题目描述
Kolya has a string $ s $ of length $ n $ consisting of lowercase and uppercase Latin letters and digits. He wants to rearrange the symbols in $ s $ and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, such as madam or racecar. Your task is to help Kolya and determine the minimum number of palindromes of equal lengths to cut $ s $ into, if it is allowed to rearrange letters in $ s $ before cuttings.输入输出格式
输入格式
The first line contains an integer $ n $ ( $ 1<=n<=4·10^{5} $ ) — the length of string $ s $ . The second line contains a string $ s $ of length $ n $ consisting of lowercase and uppercase Latin letters and digits.
输出格式
Print to the first line an integer $ k $ — minimum number of palindromes into which you can cut a given string. Print to the second line $ k $ strings — the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.
输入输出样例
输入样例 #1
6
aabaac
输出样例 #1
2
aba aca
输入样例 #2
8
0rTrT022
输出样例 #2
1
02TrrT20
输入样例 #3
2
aA
输出样例 #3
2
a A