CF196A.Lexicographically Maximum Subsequence
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum 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|.
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 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 lines are compared like their ASCII codes.
你有一个仅由小写英文字母组成的字符串 s。请找出其字典序最大的子序列。
我们称一个非空字符串 s[p1p2…pk]=sp1sp2…spk(其中 1≤p1<p2<…<pk≤∣s∣)为字符串 s=s1s2…s∣s∣ 的一个子序列。
字符串 x=x1x2…x∣x∣ 在字典序上大于字符串 y=y1y2…y∣y∣,当且仅当以下任一条件成立:
- ∣x∣>∣y∣ 且 x1=y1,x2=y2,…,x∣y∣=y∣y∣;
- 或存在某个数 r(满足 r<∣x∣ 且 r<∣y∣),使得 x1=y1,x2=y2,…,xr=yr,且 xr+1>yr+1。
字符串中字符的比较依据其 ASCII 码值。
输入格式
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
单行包含一个非空字符串 s,该字符串仅由小写英文字母组成。字符串的长度不超过 105。
输出格式
Print the lexicographically maximum subsequence of string s.
输出字符串 s 的字典序最大的子序列。
输入输出样例
输入#1
ababba
输出#1
bbba
输入#2
abbcbccacbbcbaaba
输出#2
cccccbba
说明/提示
Let's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).
The first sample: aBaBBA
The second sample: abbCbCCaCbbCBaaBA
我们来看几个样例,观察所求子序列的形态(它们用大写粗体字母标出)。
第一个样例:aBaBBA
第二个样例:abbCbCCaCbbCBaaBA
输入解题思路,AI测评打分。不知道怎么写?