#x1007. CF1654F Minimal String Xoration
CF1654F Minimal String Xoration
Minimal String Xoration
题面翻译
- 给定一个长度为 ,只包含小写字母的字符串 。
- 你可以将字符串的下标全部异或一个 的整数 ,即构造一个与 等长的新字符串 ,使得 。
- 最小化 的字典序,并输出字典序最小的 。
- 。
题目描述
You are given an integer and a string consisting of lowercase letters of the English alphabet. The characters of the string are .
A string of length (whose characters are denoted by ) is a xoration of if there exists an integer ( ) such that, for each , (where denotes the operation bitwise XOR).
Find the lexicographically minimal xoration of .
A string is lexicographically smaller than a string if and only if one of the following holds:
- is a prefix of , but ;
- in the first position where and differ, the string has a letter that appears earlier in the alphabet than the corresponding letter in .
输入格式
The first line contains a single integer ( ).
The second line contains a string consisting of lowercase letters of the English alphabet.
输出格式
Print a single line containing the lexicographically minimal xoration of .
样例 #1
样例输入 #1
2
acba
样例输出 #1
abca
样例 #2
样例输入 #2
3
bcbaaabb
样例输出 #2
aabbbcba
样例 #3
样例输入 #3
4
bdbcbccdbdbaaccd
样例输出 #3
abdbdccacbdbdccb
样例 #4
样例输入 #4
5
ccfcffccccccffcfcfccfffffcccccff
样例输出 #4
cccccffffcccccffccfcffcccccfffff
样例 #5
样例输入 #5
1
zz
样例输出 #5
zz
提示
In the first test, the lexicographically minimal xoration of "acba" is "abca". It's a xoration because, for ,
- "a";
- "b";
- "c";
- "a".
There isn't any xoration of lexicographically smaller than "abca".In the second test, the minimal string xoration corresponds to choosing in the definition of xoration.
In the third test, the minimal string xoration corresponds to choosing in the definition of xoration.
In the fourth test, the minimal string xoration corresponds to choosing in the definition of xoration.
In the fifth test, the minimal string xoration corresponds to choosing either or in the definition of xoration.