Codeforces Round 423 (Div. 1, rated, based on VK Cup Finals)
C
DNA Evolution
Codeforces
2100
原题
← BD →
翻译中…

Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A", "T", "G", "C". A DNA strand is a sequence of nucleotides. Scientists decided to track evolution of a rare species, which DNA strand was string $*s*$ initially.

翻译中…

Evolution of the species is described as a sequence of changes in the DNA. Every change is a change of some nucleotide, for example, the following change can happen in DNA strand "AAGC": the second nucleotide can change to "T" so that the resulting DNA strand is "ATGC".

翻译中…

Scientists know that some segments of the DNA strand can be affected by some unknown infections. They can represent an infection as a sequence of nucleotides. Scientists are interested if there are any changes caused by some infections. Thus they sometimes want to know the value of impact of some infection to some segment of the DNA. This value is computed as follows:

翻译中…
  • Let the infection be represented as a string $*e*$, and let scientists be interested in DNA strand segment starting from position $*l*$ to position $*r*$, inclusive.
  • Prefix of the string $*eee*...$ (i.e. the string that consists of infinitely many repeats of string $*e*$) is written under the string $*s*$ from position $*l*$ to position $*r*$, inclusive.
  • The value of impact is the number of positions where letter of string $*s*$ coincided with the letter written under it.
翻译中…

Being a developer, Innokenty is interested in bioinformatics also, so the scientists asked him for help. Innokenty is busy preparing VK Cup, so he decided to delegate the problem to the competitors. Help the scientists!

翻译中…

Input

翻译中…

The first line contains the string $*s*$ ($1 ≤ |*s*| ≤ 10^{5}$) that describes the initial DNA strand. It consists only of capital English letters "A", "T", "G" and "C".

翻译中…

The next line contains single integer $*q*$ ($1 ≤ *q* ≤ 10^{5}$) — the number of events.

翻译中…

After that, $*q*$ lines follow, each describes one event. Each of the lines has one of two formats:

翻译中…
  • 1 x c, where $*x*$ is an integer ($1 ≤ *x* ≤ |*s*|$), and $*c*$ is a letter "A", "T", "G" or "C", which means that there is a change in the DNA: the nucleotide at position $*x*$ is now $*c*$.
  • 2 l r e, where $*l*$, $*r*$ are integers ($1 ≤ *l* ≤ *r* ≤ |*s*|$), and $*e*$ is a string of letters "A", "T", "G" and "C" ($1 ≤ |*e*| ≤ 10$), which means that scientists are interested in the value of impact of infection $*e*$ to the segment of DNA strand from position $*l*$ to position $*r*$, inclusive.
翻译中…

Output

翻译中…

For each scientists' query (second type query) print a single integer in a new line — the value of impact of the infection on the DNA.

翻译中…

Note

翻译中…

Consider the first example. In the first query of second type all characters coincide, so the answer is $8$. In the second query we compare string "TTTTT..." and the substring "TGCAT". There are two matches. In the third query, after the DNA change, we compare string "TATAT..."' with substring "TGTAT". There are $4$ matches.

翻译中…

样例

Input #1
ATGCATGC
4
2 1 8 ATGC
2 2 6 TTT
1 4 T
2 2 6 TA
Output #1
8
2
4
InputCopy OutputCopy
Input #2
GAGTTGTTAA
6
2 3 4 TATGGTG
1 1 T
1 6 G
2 5 9 AGTAATA
1 10 G
2 2 6 TTGT
Output #2
0
3
1
InputCopy OutputCopy
题目信息
题号
827C
时间限制
2 s
内存限制
512 MB
标签
数据结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。