今天参加了微软在线编程挑战,总共4道题两个小时(全英文)。第一道题不难可是感觉题意讲的不是很明却比较难懂,不过这道题还是很快的搞定。接下来就是漫长的思考....。第二道题也不是很难(本人采用全排列)可是在实现不可重复的全排列时花费了大量时间,导致最后没发完成整个题目草草提交。这样结束了自己的第一次在线编程的经历。
经过这次编程使我感悟最深的有这么几点:
1,在线编程要求很严格的输入和输出格式,如果不按照格式根本就无法通过。(自己就在这个上面吃亏,以前都是随意设置输入输出,面对所有输入输出都要求用stdin,stdout时感觉感觉好难)。
2,感觉自己在线编程经验太少(这是第一次),速度比较慢。
3,算法能力,解决实际问题的能力有待提高。
下面给出一道这次试题的样例:
String reorder
-
aabbccdd 007799aabbccddeeff113355zz 1234.89898 abcdefabcdefabcdefaaaaaaaaaaaaaabbbbbbbddddddee
样例输出
-
abcdabcd 013579abcdefz013579abcdefz <invalid input string> abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa
Description
For this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’).
Your program should reorder and split all input string characters into multiple segments, and output all segments as one concatenated string. The following requirements should also be met,
1. Characters in each segment should be in strictly increasing order. For ordering, ‘9’ is larger than ‘0’, ‘a’ is larger than ‘9’, and ‘z’ is larger than ‘a’ (basically following ASCII character order).
2. Characters in the second segment must be the same as or a subset of the first segment; and every following segment must be the same as or a subset of its previous segment.
Your program should output string “<invalid input string>” when the input contains any invalid characters (i.e., outside the '0'-'9' and 'a'-'z' range).
Input
Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.
Output
For each case, print exactly one line with the reordered string based on the criteria above.