Medium Beginners Problems > Ad-hoc

Given an string **s** and **q** query. each query consist a single integer **k**. you have to find how many pair of index **(i,j)** are there such **j>=i and i+j=k and s[i]=s[j].** string start at index 0, end at index n-1, where n is the length of string. string consist only lower case english letter. length of string will be less than equal **1000**, there will be at most **2*10<sup>3</sup>+5** queries per test case and maximum **1000** test cases. Input: ------ Number of test case in first line, then each test case start with n (length of string) in a line , then the string in next line, 3rd line is a integer **q** (number of query) and next **q** line consist k<sub>i</sub>. **0<= k<sub>i</sub><=2n** Output: ------- For each query , print a single integer in a line, which is the answer of that query Sample Input ------------ 1 6 eiging 13 0 1 2 3 4 5 6 7 8 9 10 11 12 Sample Output ------------- 1 0 1 0 2 0 1 1 1 0 1 0 0

Md. Tariqul Islam