编程介的小学生 2020-02-12 21:30 采纳率: 20.3%
浏览 107

Dynamic Love 怎么计算的

Problem Description
As a famous person with universal love, changing girlfriend too often makes me harassment because I can't keep their name in mind timely. To remember who is my lover now, I buy a magic password-box from a wizard.
As a faithful atheist, I do not believe that it is caused by magic power. By doing a deep research, I find that all "magic" factors are just because a small software inside the box. Because the software only uses some simple data structure, it has a dissatisfied complexity.
Now I shortly introduce the principle of the software.
We will support a string with dynamic length and three kinds of operations on it. You can assume that we will always have an initial string.
*1. You will receive a short string, and you should connect it after the original string to make the new string.
*2. You will receive an integer len, and you should answer the query: for each index i (1 <= i <= LEN(nowString)), we will get a sub-string from i to i + len - 1 (if i + len - 1 > LEN(nowString), you should make the suffix from index i as its sub-string). You should output the index i whose sub-string has minimum lexicographic.
*3. You will receive an integer len. You should delete the suffix whose length is len from the string now and get a new string.
As a former ACMer, I want to make a new production with better execution speed. But I am not good at data structure, so I need your help.

Input
There are multiple test cases.
The first line contains a string as the initial string.
The next line contains an integer m (1 <= m <= 100,000) indicating the number of the operations.
Each of the next m lines begins with an integer k (1 <= k <= 3) indicating the kind of operation. If k = 1, it is followed by a short non-empty string, otherwise it is followed by an integer len.
We guarantee that the total length of the initial string and all short strings are not more than 100,000. And for each query, the len is not more than 1000 and the total sum of len is not more than 100,000.
All characters in the input are lower case.

Output
For each test case, you should output several lines.
For each query, you should output a line indicating the index i whose sub-string has minimum lexicographic. If more answers exist, output the minimal index.

Sample Input
aacbab
5
2 2
1 aaa
2 3
3 2
2 3

Sample Output
1
9
7

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 elmos524.33 eeprom的读写问题
    • ¥15 使用Java milo连接Kepserver服务端报错?
    • ¥15 用ADS设计一款的射频功率放大器
    • ¥15 怎么求交点连线的理论解?
    • ¥20 软件开发方法学习来了
    • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成
    • ¥15 HC32L176调试了一个通过TIMER5+DMA驱动WS2812B
    • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
    • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
    • ¥15 Python程序,深度学习,有偿私