#P5821. 【L&K R-03】密码串匹配
【L&K R-03】密码串匹配
Description
After getting destroyed by the judge, Little L reflected and decided to use a safer password. Little L designed a password that may be as long as characters and consists only of lowercase letters, and he guarantees that nobody can remember it, guess it, or brute-force it (including Little L himself).
To avoid forgetting the whole password string (no need to avoid it; he has already forgotten it), Little L wrote a program that can store his password string , but cannot output it directly (because others might use this program). The first time, Little L reconstructs a string of length from memory. Later, he will modify one character of based on the program’s output. This program can compute the mismatch degree between the current guess string and the substring of with the same length.
Define the value of character a as , character b as , and so on, up to character z as . Define the mismatch degree of two strings as the sum of the squares of the differences of their values at corresponding positions.
Now, Little L wants to know whether his program is correct. Please write a similar program as well.
Input Format
The first line contains three integers , representing the length of the password string , the length of the guess string , and the number of operations .
The next two lines contain two strings, which are and .
The next lines each start with an integer , indicating the type of operation:
- If , then an integer follows, meaning you need to query the mismatch degree between and the substring of of length starting from position .
- If , then an integer and a character follow, meaning you modify the -th character of to make it equal to .
Output Format
For each operation of type , output one line containing the required value.
8 5 3
iamangry
anger
1 4
2 2 m
1 2
218
238
Hint
Please note the special time limit of this problem.
The data size is large, so please optimize constants carefully.
To prevent the problem from being too strict on runtime, this problem provides Bajuyang. You can paste it directly at the very beginning of your code and submit.
In this problem, all indices start from .
- Subtask #1: points, guaranteed .
- Subtask #2: points, guaranteed there is no operation type .
- Subtask #3: points, guaranteed .
For of the testdata, it is guaranteed that and .
For all operations of type , it is guaranteed that .
For all operations of type , it is guaranteed that .
Sample Explanation
$(a-a)^2+(n-n)^2+(g-g)^2+(r-e)^2+(y-r)^2=13^2+7^2=218$.
$(a-a)^2+(m-m)^2+(a-g)^2+(n-e)^2+(g-r)^2=6^2+9^2+11^2=238$。
Translated by ChatGPT 5
京公网安备 11011102002149号