Hacking The Counter
All submissions for this problem are available.
Ammy is a girl and a beginner level programmer who loves gambling very much.She goes into a casino which is particularly designed for programmers like you
where the process of gambling is different than the other casinos.There is a counter machine in the casino on which the gambling has to be done.The counter machine
counts from 0 to 9,a to z and A to Z .The process of gambling is as follows:
1. The manager shows N number of strings to all the gamblers.The string S contains both the numbers and the characters.
2. With the string he also displays a number M related to each of the string.
3. Manager then ask all the gamblers to choose a number
4. Manager then runs the counter.The counter displays a number V .The person who will guess the correct number will be the winner.
Ammy as a programmer knows some of hacking.By using her skills she was able to recognize the working of counter.The counter works as follows:
1. The counter first decrements each element by the given number M in the String. This applies to all the N strings displayed.
2. The Strings then obtained will have some characters in common. The counter displays the number of elements V which are common in all the obtained Strings.
Ammy needs some help in hacking the counter in order to win the gambling.Your task is to output the number displayed by the counter.
Input Description :
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The Second line contains the length of each string L
and the number of strings N.
- Next N lines contains the String S and a number M.
- For each test case, output a single line containing the value of V which is the number of elements common in all the obtained strings.
- 1 ≤ T ≤ 10
- 1 ≤ L ≤ 62
- 2 ≤ N ≤ 4
- 1 ≤ M ≤ 10
- There will be no repetition of the characters in a String S
1 7 2 b1230cd 5 a41cef6 4Output:
Example case 1.
The first line contains the length of all the strings L which is 7 and the number of strings N which is 2.
The second line contains the string S and a number M with which each element has to be decremented.
The first string is b1230cd
If b is decremented 5 times the output is w then 1 is decremented 5 times output is 6 so in this way after decrementing all the elements.The resulting string is w6785xy.
Similarly decrementing each element 4 times in the second string the output is w07yab2.
After comparing both the strings w6785xy and w07yab2, there are 3 elements in common w,7 and y so the answer is 3.
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.