15北京网络赛 B题

这是一道关于模拟Bad Boss在文本编辑器中进行输入操作的编程题。题目描述了Bad Boss如何通过键盘输入小写字母、特殊指令来编辑一行文本。文本编辑器有两种模式:插入模式和覆盖模式。你需要根据输入的指令,判断Bad Boss最终在文本编辑器中看到的内容。
摘要由CSDN通过智能技术生成

题目描述:

题目2 : Mission Impossible 6

时间限制:1000ms

单点时限:1000ms

内存限制:256MB

描述

You must have seen the very famous movie series,”Mission Impossible”, from 1 to 4. And “Mission Impossible 5” is now on screen in China. Tom Cruise is just learning programming through my MOOC course, and he wants a good score. So I made him divulge the story of “Mission Impossible 6”.

In “Mission Impossible 6”, Ethan Hunt risks his life to install a mini camera in Bad Boss’s room, in order to peep at the work Bad Boss does on his computer. Unfortunately, Bad Boss moves his desk to get more sunshine, and after that Ethan can’t see the computer screen through the camera. Fortunately, Ethan can still see the keyboard. So, Ethan wants to know what Bad Boss writes on his computer by watching Bad Boss’s keyboard inputs. That job is neither exciting nor risky, so it’s really impossible for Ethan to accomplish — that’s why Tom Cruise wants to learn programming.

To simplified the problem, we assume that Bad Boss is editing a one line document, and the document consists of only lowercase letters. At first, there are nothing in the text editor window except a caret blinking at the left-most position (the starting position of the line). When Bad Boss input a lowercase letter, the letter appears at the right side of the caret, and then the caret moves to the right side of the letter just inputted. The text editor can switch between “insert mode” and “overwrite mode”. When it’s in “overwrite mode”, the newly inputted letter will overwrite the letter which is on the right of the caret(if there is one). If it’s in “insert mode”, the newly inputted letter will be inserted before the letter which is originally on the right of the caret.

Besides inputting lowercase letters, Bad Boss can do some operations by inputting some uppercase letters, as described below:

‘L’ : Moves the caret toward left by one letter. If the caret is already at the start of the line, then nothing happens.

‘R’: Moves the caret toward right by one letter. If the caret is already at the end of the line(it means that there are no letters on the right side of the caret), then nothing happens.

‘S’: Switch between “overwrite mode” and “insert mode”. At the beginning, it’s in “insert mode”.

‘D’: Delete a letter which is on the right of the caret. If the caret is already at the end of the line, then nothing happens. ‘D’ also has other effect which is described in ‘C’ operation below.

‘B’: Delete a letter which is on the left of the caret. If the caret is already at the start of the line, then nothing happens.

‘C’: Copy something to the clipboard. At first , there is nothing in the clipboard, and the “copy status” of the editor is set to “NOTHING”. When key ‘C’ is pressed:

If copy status is “NOTHING”, copy status will be changed into “START”, and the current position of caret is saved as “copy position 1”.

if copy status is “START “, copy status will be changed into “NOTHING” and the letters between current caret position and the saved “copy position 1” will be copied into clipboard(The old content in the clipboard is replaced). If those two positions are the same, clipboard will be cleared.

Please note that , if any letter except ‘L’ , ‘R’ and ‘D’ is inputted when copy status is “START”, copy status will changed into “NOTHING” immediately, not affecting the inputted letter taking its own effect as mention above. If ‘D’ is inputted when copy status is “START”, copy status will changed into “NOTHING” immediately, and the letters between current caret position and “copy position 1” will be deleted.

‘V’: Paste the content in the clipboard into the right of the caret. If there is nothing in the clipboard, nothing happens. In “insertion mode”, the pasted content is inserted. If it’s in “overwrite mode” and there are k letters in the clipboard, then k letters will be overwrote. In “overwrite mode”, if the number of

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值