report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Gnimmah distance - MarisaOJ: Marisa Online Judge

Gnimmah distance

Time limit: 1000 ms
Memory limit: 256 MB
The Gnimmah distance between two strings $s$ and $t$ of equal length is the number of positions at which the corresponding characters are similar. For example, string `abc` and `aba` have the Gnimmah distance of 2 as the first and the second characters of 2 string are equal. Given 2 strings $A, B$ and $A$ is always longer than $B$. Calculate the sum of Gnimmah distance between $B$ and each substring of length $|B|$ of $A$. ### Input - The first line is string $A$. - The second line is string $B$. ### Output - Print an integer, the sum of Gnimmah distance between each substring of length $|B|$ of $A$, and $B$. ### Constraints - $1 \le |A|, |B| \le 10^5$. - Both strings only consist of lowercase English letters. ### Example Input: ``` aaba abc ``` Output: ``` 3 ```
Introduction to Binary Search
Binary search
Binary search 2
Binary search 3
Large subarray
Count query
Counting pairs
The k-th candy
Triangle edges
Hamming number
Consecutive integers
Gnimmah distance
Subarray
Topic
Binary search
Rating 1400
Solution (1) Solution