AtCoder Grand Contest 026
E
Synchronized Subsequence
AtCoder
⌀ 3016
原题
← DF →
翻译中…

Problem Statement

翻译中…

You are given a string $S$ of length $2N$, containing $N$ occurrences of a and $N$ occurrences of b.

翻译中…

You will choose some of the characters in $S$. Here, for each $i = 1,2,...,N$, it is not allowed to choose exactly one of the following two: the $i$-th occurrence of a and the $i$-th occurrence of b. (That is, you can only choose both or neither.) Then, you will concatenate the chosen characters (without changing the order).

翻译中…

Find the lexicographically largest string that can be obtained in this way.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 3000$
  • $S$ is a string of length $2N$ containing $N$ occurrences of a and $N$ occurrences of b.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
S

翻译中…

Output

翻译中…

Print the lexicographically largest string that satisfies the condition.

翻译中…

样例

Input #1
3
aababb
Output #1
abab
A subsequence of $T$ obtained from taking the first, third, fourth and sixth characters in $S$, satisfies the condition.
Input #2
3
bbabaa
Output #2
bbabaa
You can choose all the characters.
Input #3
6
bbbaabbabaaa
Output #3
bbbabaaa
Input #4
9
abbbaababaababbaba
Output #4
bbaababababa
题目信息
题号
agc026_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。