PivotOJ

Mutating DNA

시간 제한: 1000ms메모리 제한: 2048MB출처: IOI 2021BOJ 22046

문제

Grace is a biologist working in a bioinformatics firm in Singapore. As part of her job, she analyses the DNA sequences of various organisms. A DNA sequence is defined as a string consisting of characters "A", "T", and "C". Note that in this task DNA sequences do not contain character "G".

We define a mutation to be an operation on a DNA sequence where two elements of the sequence are swapped. For example a single mutation can transform "ACTA" into "AATC" by swapping the highlighted characters "A" and "C".

The mutation distance between two sequences is the minimum number of mutations required to transform one sequence into the other, or 1-1 if it is not possible to transform one sequence into the other by using mutations.

Grace is analysing two DNA sequences aa and bb, both consisting of nn elements with indices from 00 to n1n - 1. Your task is to help Grace answer qq questions of the form: what is the mutation distance between the substring a[x..y]a[x..y] and the substring b[x..y]b[x..y]? Here, a substring s[x..y]s[x..y] of a DNA sequence ss is defined to be a sequence of consecutive characters of s, whose indices are xx to yy inclusive. In other words, s[x..y]s[x..y] is the sequence s[x]s[x+1]s[y]s[x]s[x + 1] \dots s[y].

코드를 제출하려면 로그인하세요.