IBMOA #7
Vowel-Bookended Strings (Range Queries)
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & RangesStrings
Each query gives a 1-based closed interval l-r; count the strings in it whose first and last characters are both lowercase vowels aeiou. A single-character vowel qualifies.
Input
The first line contains n q, followed by n lines of non-empty lowercase strings, then q lines of l-r. On this site n,q≤100000, total characters ≤10^6, 1≤l≤r≤n.
Output
Output q integers in query order.
Example 1
Input:
5 2
aba
bcb
ece
aa
e
1-3
2-5
Output:
2 3
Example 2
Input:
1 1
a
1-1
Output:
1
Example 3
Input:
2 1
ab
ba
1-2
Output:
0
Example notes
The examples give 2 3; 1; and 0 respectively.
Editorial
Loading solution…