CF827C.DNA Evolution

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ss 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 ee , and let scientists be interested in DNA strand segment starting from position ll to position rr , inclusive.
  • Prefix of the string eee...eee... (i.e. the string that consists of infinitely many repeats of string ee ) is written under the string ss from position ll to position rr , inclusive.
  • The value of impact is the number of positions where letter of string ss 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!

输入格式

The first line contains the string ss ( 1<=s<=1051<=|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 qq ( 1<=q<=1051<=q<=10^{5} ) — the number of events.

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

  • 1 x c, where xx is an integer ( 1<=x<=s1<=x<=|s| ), and cc is a letter "A", "T", "G" or "C", which means that there is a change in the DNA: the nucleotide at position xx is now cc .
  • 2 l r e, where ll , rr are integers ( 1<=l<=r<=s1<=l<=r<=|s| ), and ee is a string of letters "A", "T", "G" and "C" ( 1<=e<=101<=|e|<=10 ), which means that scientists are interested in the value of impact of infection ee to the segment of DNA strand from position ll to position rr , inclusive.

输出格式

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.

输入输出样例

  • 输入#1

    ATGCATGC
    4
    2 1 8 ATGC
    2 2 6 TTT
    1 4 T
    2 2 6 TA
    

    输出#1

    8
    2
    4
    
  • 输入#2

    GAGTTGTTAA
    6
    2 3 4 TATGGTG
    1 1 T
    1 6 G
    2 5 9 AGTAATA
    1 10 G
    2 2 6 TTGT
    

    输出#2

    0
    3
    1
    

说明/提示

Consider the first example. In the first query of second type all characters coincide, so the answer is 88 . 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 44 matches.

首页