Codeforces Round 127 (Div. 2)
A
LLPS
Codeforces
800
原题
←B →
翻译中…

This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.

翻译中…

You are given string $*s*$ consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.

翻译中…

We'll call a non-empty string $*s*[*p*_{1}$$*p*_{2}... *p*_{*k*}]$ = $*s*_{*p*_{1}}*s*_{*p*_{2}}... *s*_{*p*_{*k*}}$ ($1$ $≤$ $*p*_{1} < *p*_{2} < ... < *p*_{*k*}$ $≤$ $|*s*|$) a subsequence of string $*s*$ = $*s*_{1}$$*s*_{2}... *s*_{|*s*|}$, where $|*s*|$ is the length of string $*s*$. For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".

翻译中…

String $*x*$ = $*x*_{1}$$*x*_{2}... *x*_{|*x*|}$ is lexicographically larger than string $*y*$ = $*y*_{1}$$*y*_{2}... *y*_{|*y*|}$ if either $|*x*|$ > $|*y*|$ and $*x*_{1} = *y*_{1}$, $*x*_{2} = *y*_{2}$, ..., $*x*_{|*y*|} = *y*_{|*y*|}$, or there exists such number $*r*$ ($*r* < |*x*|$, $*r* < |*y*|$) that $*x*_{1} = *y*_{1}$, $*x*_{2} = *y*_{2}$, ..., $*x*_{*r*} = *y*_{*r*}$ and $*x*_{*r*  +  1} > *y*_{*r*  +  1}$. Characters in the strings are compared according to their ASCII codes. For example, string "ranger" is lexicographically larger than string "racecar" and string "poster" is lexicographically larger than string "post".

翻译中…

String $*s*$ = $*s*_{1}$$*s*_{2}... *s*_{|*s*|}$ is a palindrome if it matches string $*rev*(*s*)$ = $*s*_{|*s*|}$$*s*_{|*s*| - 1}... *s*_{1}$. In other words, a string is a palindrome if it reads the same way from left to right and from right to left. For example, palindromic strings are "racecar", "refer" and "z".

翻译中…

Input

翻译中…

The only input line contains a non-empty string $*s*$ consisting of lowercase English letters only. Its length does not exceed $10$.

翻译中…

Output

翻译中…

Print the lexicographically largest palindromic subsequence of string $*s*$.

翻译中…

Note

翻译中…

Among all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr".

翻译中…

样例

Input #1
radar
Output #1
rr
InputCopy OutputCopy
Input #2
bowwowwow
Output #2
wwwww
InputCopy OutputCopy
Input #3
codeforces
Output #3
s
InputCopy OutputCopy
Input #4
mississipp
Output #4
ssss
InputCopy OutputCopy
题目信息
题号
202A
时间限制
2 s
内存限制
256 MB
标签
二分
位运算
暴力
贪心
模拟
字符串

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