2015校赛A
2015-12-05 18:39
225 查看
Problem A. Deleting Character
Description
You have a string consists of N characters, you want to make a new string by deleting one of the characters from the original string. In which way you can make a string with the largest lexicographic order. Lexicographic order is defined as below:
Comparing string A and string B, you should start from the first characters of them, if A[0]>B[0] then A is lexicographically larger than B, vice versa. But if A[0]==B[0], you should take into the next characters them, comparing A[1] and A[1] and so on. Notice that string "ab" is lexicographically smaller than string "abc".
Input
The first line is a number T which indicates the number of test cases.
For each test case there is a number N (1<=N<=100000) which indicates the length of the string and the following line is the input string.
Output
For each test case output a string which is lexicographically largest.
Sample Input
2
3
abc
5
power
Sample Output
bc
pwer
Hint
String “abc” can transfer into “bc”, “ac” and “ab”, and “bc” has the largest lexicographic order.
题意:给一个字符串,删掉一个字符,求删掉一个字符后的字典序最大的字符串,输出。
是个签到题,然而我没过。
从前到后枚举,找出第一个比后一位字符小的字符。
我做成了找出一个比前面小而且比后面小的字符。呵呵
Description
You have a string consists of N characters, you want to make a new string by deleting one of the characters from the original string. In which way you can make a string with the largest lexicographic order. Lexicographic order is defined as below:
Comparing string A and string B, you should start from the first characters of them, if A[0]>B[0] then A is lexicographically larger than B, vice versa. But if A[0]==B[0], you should take into the next characters them, comparing A[1] and A[1] and so on. Notice that string "ab" is lexicographically smaller than string "abc".
Input
The first line is a number T which indicates the number of test cases.
For each test case there is a number N (1<=N<=100000) which indicates the length of the string and the following line is the input string.
Output
For each test case output a string which is lexicographically largest.
Sample Input
2
3
abc
5
power
Sample Output
bc
pwer
Hint
String “abc” can transfer into “bc”, “ac” and “ab”, and “bc” has the largest lexicographic order.
题意:给一个字符串,删掉一个字符,求删掉一个字符后的字典序最大的字符串,输出。
是个签到题,然而我没过。
从前到后枚举,找出第一个比后一位字符小的字符。
我做成了找出一个比前面小而且比后面小的字符。呵呵
相关文章推荐
- eclipse中删除所有的空行
- C++ STL基本容器比较
- 深入浅出java虚拟机系列:(一)jvm 内存区域
- Android中获取屏幕信息DisplayMetrics的用法
- hihoCoder: Individual Income Tax
- 算法常用术语中英对照
- 人人都能开发物联网(一.目标)
- 为IIS Express添加MIME映射
- 【五】ODB - C++ 表单列函数count、min、max(V1.0)
- iOS-UITextField-通知
- 第15周实践项目-哈希表
- Android之动画精讲一:从setTranslationX谈属性动画和view动画的区别
- win10开启wifi热点
- 关于MySQL数据导出导入
- 蓝桥杯 圆的面积(实数输出)
- CentOS 7 编译安装PHP7
- zookeeper 简介
- 3280 Cheapest Palindrome(尺取法)
- java 基础(异常处理)
- 《1024伐木累》-宝贝儿,可不可以