#P11279. 「GFOI Round 2」Abstract String Basic
「GFOI Round 2」Abstract String Basic
Description
Charlie is taking a course called Basics of Abstract Strings.
Definition 3.1: For two lowercase strings and of the same length, their similarity is defined as the number of matching characters in corresponding positions. Formally, if , then the similarity between and is given by $\psi(S, T) = \sum\limits_{i=1}^n \sum\limits_{j=1}^n [i = j][S_i = T_j]$.
Lemma 3.1: For any lowercase string , there exists a unique lowercase string that maximizes .
Proof of Lemma 3.1: ...
Charlie’s mind begins to wander, and he starts scribbling aimlessly on his paper. Suddenly, he comes up with a new idea: what if he defines the dissimilarity between and as the number of pairs where both the position and the character are different? Formally, this similarity can be defined as $\tilde{\psi}(S, T) = \sum\limits_{i=1}^n \sum\limits_{j=1}^n [i \neq j][S_i \neq T_j]$. This whimsical definition snaps Charlie out of his daydream. Now, he wonders: what kind of lowercase string would maximize the dissimilarity between and ?
Note: The square brackets represent Iverson brackets, which evaluate to if the condition is true, and otherwise.
Input Format
The first line contains a positive integer .
The second line contains a string of length , consisting only of lowercase letters.
Output Format
Output a single line containing a lowercase string , representing your answer. You need to maximize the dissimilarity between and . If there are multiple answers, output any.
9
cbbccxxxx
godfather
26
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
28
aabcdefghijklmnopqrstuvwxyzz
cybcdefghijklmnopqrstuvwxycy
Hint
Sample Explanation
When , , reaching the maximum value. Note that there may be more than one valid answer.
Subtasks and Constraints
| Subtask ID | Special Properties | Score | |
|---|---|---|---|
| Tests are samples | |||
| No | |||
doesn't contain the character z |
|||
| No | |||
For all tests, it is guaranteed that:
- ;
- consists only of lowercase letters.
京公网安备 11011102002149号