题干:

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[p1p2... pk] = sp1sp2... spk (1  ≤  p1 < p2 < ... < pk  ≤ |s|) a subsequence of string s = s1s2... s|s|, where |s| is the length of string s. For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".

String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y| if either |x| > |y| and x1 = y1, x2 = y2, ..., x|y| = y|y|, or there exists such number r (r < |x|, r < |y|) that x1 = y1, x2 = y2, ..., xr = yr and xr  +  1 > yr  +  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 = s1s2... s|s| is a palindrome if it matches string rev(s) = s|s|s|s| - 1... s1. 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.

Examples

Input

radar

Output

rr

Input

bowwowwow

Output

wwwww

Input

codeforces

Output

s

Input

mississipp

Output

ssss

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

题目大意:

给你一个字符串,让你找到字典序最大的回文子序列。(给出了字典序的定义和子序列的定义)

解题报告:

因为数据量是10,本来想写搜索,但是看了眼样例,发现一个小规律,答案都是相同的字符,那么结论就出来了,,,找到ASCII最大的那个字符,输出个数就可以了。

证明可以用样例,,,你就算是选了一些比较大的回文串比如abzcczba,那么完全可以用其中最大的那个字符z来打头。于是我们证明了一定用最大的那个字符打头,那么我们假设字符串zaaz,那么完全可以直接取zz,于是得出结论。。

AC代码:

#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
//string s[5000],str;
//int len;
//int top;
//bool fit(string ss) {
//  int l = ss.length();
//  if(l == 0) return 0;
//  for(int i = 0; i<l/2; i++) {
//      if(ss[i] != ss[l-i]) return  0 ;
//  }
//  return 1;
//}
//void dfs(int cur,string tmp) {
//  if(cur >= len) return ;
//  if(fit(tmp)) s[++top] = tmp;
//  dfs(cur+1,tmp+str[cur+1]);
//  dfs(cur+1,tmp);
//}
int main()
{string str;cin>>str;int len = str.length();
//  string w = string(1,str[0]);
//  dfs(0,w);
//  printf("%d\n",top);
//  for(int i = 1; i<=top; i++) {
//      cout << s[i] << endl;
//  }char cur = 0;for(int i = 0; i<len; i++) {if(str[i] > cur) cur = str[i];}int cnt = 0;for(int i = 0; i<len; i++) {if(str[i] == cur) cnt++;}for(int i = 1; i<=cnt; i++) {putchar(cur);}return 0 ;}

(话说代码里那个搜索不太对好像,,,也没debug)

【CodeForces - 202A】LLPS (思维,字符串)相关推荐

  1. 【CodeForces - 202A】【LLPS】

    题目: This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too ...

  2. codeforces 有意思的思维题 1 ~ 15

    codeforces 思维题 1.给定数组,求满足i < j and ai * aj = i + j的数对数量 2.第 i 步向前跳 i 步或后退 1 步 3.给两个点,求正方形的另两个点 4. ...

  3. CodeForces - 364A Matrix(思维+数学)

    题目链接:点击查看 题目大意:给出一个长度为 n 的,只由十进制数字组成的字符串 s,可以构造出一个大小为 n * n 的矩阵,构造方法如下:b[ i ][ j ] = s[ i ] * s[ j ] ...

  4. Task On The Board CodeForces - 1367D(思维)

    Polycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This strin ...

  5. codeforces数学1600day4[贪心数学公式推导CodeForces - 1151D ,思维CodeForces - 1085C,数论同余+组合计数 CodeForces - 1056B]

    A - Stas and the Queue at the Buffet CodeForces - 1151D 题目大意:就是给你n个人在排队,每个人都有一个ai值和bi值,每个人的不满意度就是f(i ...

  6. CodeForces - 1422E Minlexes(dp+字符串)

    题目链接:点击查看 题目大意:对一个长度为 n 的字符串 s 来说,可以进行的操作如下: 选出一个二元对 ( i , i + 1 ) 满足 i >= 0 && i + 1 < ...

  7. CodeForces - 985F Isomorphic Strings(字符串哈希)

    题目链接:点击查看 题目大意:首先规定同构字符串,若字符串s和字符串t互为同构字符串,则必须满足: 两个字符串长度相同 s中的字符种类数与t中的字符种类数相同 s中的每一个字母在t中都有对应,且必须是 ...

  8. CodeForces - 1200E Compress Words(字符串哈希)

    题目链接:点击查看 题目大意:给出n个字符串,现在需要将其依次合并,合并的规则是如果相邻两个字符串中的前后缀有相同的,则合并后省略掉后面字符串的前缀,我们需要保证这个相同的前后缀如果存在的情况下必须最 ...

  9. Orac and Game of Life CodeForces - 1350E(思维+BFS)

    Please notice the unusual memory limit of this problem. Orac likes games. Recently he came up with t ...

最新文章

  1. 概率论中指数分布介绍及C++11中std::exponential_distribution的使用
  2. Dorado7功能及技术特点
  3. OpenCV下PCA降维
  4. 【Linux 内核 内存管理】Linux 内核堆内存管理 ② ( 动态分配堆内存方式 | brk 系统调用 | mmap 系统调用 | brk 系统调用源码介绍 )
  5. 【实验】利用系统自带脚本utlsampl.sql创建scott用户及样本数据
  6. 【NLP傻瓜式教程】手把手带你HAN文本分类(附代码)
  7. FFMPEG结构体分析:AVCodecContext(转)
  8. (一) : iview-form 表单循环数组 - 验证规则
  9. session的工作原理[择]
  10. 关于.NET5在IIS中部署的几个问题总结
  11. C语言(CED)gameboy接馅饼问题
  12. webservice传递特殊字符时的解决的方法
  13. python培训价目表-Python培训一般要多少钱?
  14. 动态网页技术--JSP(7)
  15. 【PCB学习笔记】绘制智能车四层板 --- PCB封装库的创建方法及现有封装调用
  16. 机器学习实战 2.3获取数据
  17. day16 正则检测、匹配次数、分组与分支、re模块、匹配参数
  18. r语言查找是否存在空值_R语言读取数据空值
  19. 解决win10只有IE可以上网,其他浏览器都无法连接网络
  20. Openssh更新升级7.9p1步骤

热门文章

  1. 第八章xgboost/lightGBM
  2. [Bugku][Web][CTF] 30-33 write up
  3. 【数据结构与算法】【算法思想】【MySQL数据库索引】B+树
  4. [小技巧][JAVA][转换]字符数组char[]与字符串String之间互相转换
  5. 用类来实现输入输出时间,定义多个类对象分别输入输出各对象的时间(时:分:秒),使用函数,数据成员不再由键盘输入,而在调用函数时由实参给出,并在函数中使用默认参数
  6. BOOT INI专辑
  7. mysql 3_mysql3
  8. ddns客户端_DDNS哪家最方便?试试看Mikrotik的ROS!
  9. 教师资格证计算机考察知识点,教师资格证考试信息技术常考知识点同步练习题.docx...
  10. java enum in class_Java 8需要一个转换,而Java 7没有 – enum.getClass/getDeclaringClass