b771. 46. Play with Words
Tags : 字串處理
Accepted rate: 23人/ 34人 ( 68%) [非即時]
評分方式:
Tolerant

最近更新 : 2016-01-13 14:09

Content

Write a program to play with words. Your program should support the following commands.

  • insert left x Insert character x at the beginning of a word.
  • insert right x Insert a character x at the end of a word.
  • insert k x Insert character x as the k-th character of this word.
  • delete left Delete a character at the beginning of a word.
  • delete right Delete a character at the end of a word.
  • delete k Delete the k-th character from the word.

Where x is a character other than spaces, and k is a number starting from 1. Initially there is nothing in this word, and after the following command the word should be "bbaac".

commandword
insert left aa
insert left aaa
insert left bbaa
insert right abaaa
insert right cbaaac
insert left bbbaaac
delete rightbbaaa
insert 4 cbbacaa
delete 5bbaca
delete 4bbaa
insert 5 cbbaac
Input

The input data contains a sequence of commands described above. All commands are valid. For example, if your program receives a "delete 5" command, we ensure that the word would has at least 5 characters for now.

Output

After processing the input commands, Your program should find out all of the longest consecutive sequence with the same character from left to right and output the character of each sequence in order, then output the length of the sequences at the end. All data should be separated by a single space.

Sample Input #1
insert left a
insert left a
insert left b
insert right a
insert right c
insert left b
delete right
insert 4 c
delete 5
delete 4
insert 5 c
Sample Output #1
b a 2
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (6%): 1.0s , <1K
公開 測資點#1 (6%): 1.0s , <1K
公開 測資點#2 (6%): 1.0s , <1K
公開 測資點#3 (6%): 1.0s , <1K
公開 測資點#4 (6%): 1.0s , <1K
公開 測資點#5 (6%): 1.0s , <1K
公開 測資點#6 (6%): 1.0s , <1K
公開 測資點#7 (6%): 1.0s , <10M
公開 測資點#8 (6%): 1.0s , <10M
公開 測資點#9 (6%): 1.0s , <10M
公開 測資點#10 (6%): 1.0s , <1K
公開 測資點#11 (6%): 1.0s , <10M
公開 測資點#12 (7%): 1.0s , <10M
公開 測資點#13 (7%): 1.0s , <10M
公開 測資點#14 (7%): 1.0s , <10M
公開 測資點#15 (7%): 1.0s , <10M
Hint :
Tags:
字串處理
出處:
NTU 批改娘 計算機程式設計課程 [管理者: morris1028 (碼畜) ]

Status Forum 排行

ID User Problem Subject Hit Post Date
26736 406490150@gm ... (我是朱朱) b771
999 2021-08-22 16:16