Type: RemoteJudge 2000ms 256MiB

LLPS

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

LLPS

题面翻译

题目描述

给你一个字符串 SS,你要在字符串中选一些字符(一个也行),使它们组成一个回文字符串,输出可以组成的最大回文串(按字典序排)。

输入格式

一个不为空串的字符串 SSSS只包含小写字母,且长度不超过 1010

输出格式

一个字符串,即最大回文串。

说明/提示

第一个样例“radar”中可以得到的回文串为"a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar",其中“rr“最大。

题目描述

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

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

We'll call a non-empty string s[p1 s[p_{1} p2... pk] p_{2}...\ p_{k}] = sp1sp2... spk s_{p1}s_{p2}...\ s_{pk} ( 1 1 <= <= p_{1}&lt;p_{2}&lt;...&lt;p_{k} <= <= s |s| ) a subsequence of string s s = s1 s_{1} s2... ss s_{2}...\ s_{|s|} , where s |s| is the length of string s s . For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".

String x x = x1 x_{1} x2... xx x_{2}...\ x_{|x|} is lexicographically larger than string y y = y1 y_{1} y2... yy y_{2}...\ y_{|y|} if either x |x| > y |y| and x1=y1 x_{1}=y_{1} , x2=y2 x_{2}=y_{2} , ..., xy=yy x_{|y|}=y_{|y|} , or there exists such number r r ( r&lt;|x| , r&lt;|y| ) that x1=y1 x_{1}=y_{1} , x2=y2 x_{2}=y_{2} , ..., xr=yr x_{r}=y_{r} and x_{r+1}&gt;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 = s1 s_{1} s2... ss s_{2}...\ s_{|s|} is a palindrome if it matches string rev(s) rev(s) = ss s_{|s|} ss1... s1 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".

输入格式

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

输出格式

Print the lexicographically largest palindromic subsequence of string s s .

样例 #1

样例输入 #1

radar

样例输出 #1

rr

样例 #2

样例输入 #2

bowwowwow

样例输出 #2

wwwww

样例 #3

样例输入 #3

codeforces

样例输出 #3

s

样例 #4

样例输入 #4

mississipp

样例输出 #4

ssss

提示

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".

20230225-字符串的应用-随堂测验

Not Attended
Status
Done
Rule
Ledo
Problem
6
Start at
2023-2-25 10:30
End at
2023-2-25 11:30
Duration
1 hour(s)
Host
Partic.
34