F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

String

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 334    Accepted Submission(s): 52


Problem Description
Alice just tries to maintain a string, with a kind of operation and a kind of query.
The kind of operation allows to insert a character at the end of the string.
The kind of query considers the substring, denoted by $T$, of the string from the $l$-th character to the $r$-th one, and asks the maximum length of substring of $T$ which appears at least twice in $T$.
If no substring appears at least twice in $T$, the outcome should be $0$.
 

Input
The first line consists a string in lowercase and a positive integer m. We use $len$ to denote the length of this string.
Each of the following m lines consists a operation or a query.

We define a temporary variable $tmp$ and it is initially set to $0$.
We use the format "1 c" to describe the operation where $(c-'a'+tmp)~mod~26+'a'$ is the new character.
We use the format "2 l r" to describe the query where $(l-1+tmp)~mod~len+1$ and $(r-1+tmp)~mod~len+1$ are the indexes of substring $T$.
We guarantee that $1\le (l-1+tmp)~mod~len+1\le (r-1+tmp)~mod~len+1\le len$ and after this query $tmp$ should be modified to the outcome.

The initial length of the string and $m$ are no more than $50000$.
 

Output
For each query, out the outcome in one line.
 

Sample Input
aabda 6 2 1 4 1 a 2 1 5 1 b 2 6 5 2 7 4
 

Sample Output
1 2 3 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-04 02:42:55, Gzip enabled