b771. 46. Play with Words
標籤 : 字串處理
通過比率 : 18人/28人 ( 64% ) [非即時]
評分方式:
Tolerant

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

內容

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
輸入說明

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.

輸出說明

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.

範例輸入 #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
範例輸出 #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
提示 :
標籤:
字串處理
出處:
NTU批改娘計算機程式設計課程 [管理者: morris1028 (碼畜) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
26736 406490150@gm ... (我是朱朱) b771
541 2021-08-22 16:16