a11y
Time limit3.5sMemory limit1024 MB
Given a string A and queries of the form letter, k, letter, count the substrings of A that start with the first letter, end with the second, and have length k+2.
- Level
Medium5 of 10
- Topics
- String, Bit manipulation, Hash map
- Solved
- No attempts yet
문제
Have you ever heard of the word a11y? It is an abbreviation of accessibility, where there are 11 characters between the a and the y. Similar abbreviations include k8s (Kubernetes) and i18n (internationalization).
You are given a string of length . Given queries, each an abbreviation made of a letter, a number, and a letter, print how many substrings of match each abbreviation. When counting, two substrings with the same content but different positions in are counted as different.
A substring of a string is a string obtained by removing zero or more characters from either end. For example, the substrings of abc are a, b, c, ab, bc, and abc, for a total of .
입력
The first line contains the string of length , which consists only of lowercase English letters. ()
The next line contains the number of queries . ()
Each of the next lines contains an abbreviation with no spaces, in the form letter, number, letter. Both letters are lowercase English letters, and the middle number is between and , inclusive.
출력
Print the answer to each query on its own line, in the order the queries are given.