CF335B.Palindrome

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Given a string s, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn't have any, print a palindrome that is a subsequence of s and is as long as possible.

给定一个字符串 ss,判断它是否包含长度恰好为 100 的回文作为子序列。如果存在,输出其中任意一个;否则,输出 ss 的一个尽可能长的回文子序列。

输入格式

The only line of the input contains one string s of length n (1 ≤ n ≤ 5·104) containing only lowercase English letters.

输入仅包含一行,该行有一个长度为 nn(1 ≤ n ≤ 5⋅1041 ≤ n ≤ 5·10^4)的字符串 ss,且 ss 仅由小写英文字母组成。

输出格式

If s contains a palindrome of length exactly 100 as a subsequence, print any palindrome of length 100 which is a subsequence of s. If s doesn't contain any palindromes of length exactly 100, print a palindrome that is a subsequence of s and is as long as possible.

If there exists multiple answers, you are allowed to print any of them.

如果字符串 ss 中存在一个长度恰好为 100 的回文子序列,则输出 ss 的任意一个长度为 100 的回文子序列;否则,输出 ss 的一个尽可能长的回文子序列。

若存在多个合法答案,输出其中任意一个即可。

输入输出样例

  • 输入#1

    bbbabcbbb

    输出#1

    bbbcbbb
  • 输入#2

    rquwmzexectvnbanemsmdufrg

    输出#2

    rumenanemur

说明/提示

A subsequence of a string is a string that can be derived from it by deleting some characters without changing the order of the remaining characters. A palindrome is a string that reads the same forward or backward.

字符串的子序列是指通过删除原字符串中的一些字符(不改变剩余字符的相对顺序)而得到的字符串。回文串是指正读和反读都相同的字符串。

输入解题思路,AI测评打分。不知道怎么写?

首页