Asya & Beautiful Strings
All submissions for this problem are available.Asya is getting bored again and this time she decided to play with strings.
She has two boxes filled with strings. She picks one string A from box-1 and another string B from box-2. She then concatenates both the strings to create a new string C ( = A + B ). She calls a string beautiful if that string contains all the 26 letters of English alphabet.
Given the strings of both the boxes, can you tell her how many such pairs (A, B) Asya can choose such that string C is a beautiful string.
- The first line of the input contains two integers, N1 and N2 denoting the number of strings in box-1 and box-2.
- Next N1 lines contain one string each, i.e, the strings in box-1.
- Next N2 lines contain one string each, i.e, the strings in box-2.
- Output a single integer, the answer to the problem.
- 1 ≤ N1, N2 ≤ 104.
- 1 ≤ |S| ≤ 103; where |S| is length of any string in the input.
- Strings contain only Upper-case English alphabets.
Input : 2 3 ABCDEFGHIJKLMNOP ABCDEFGHIJKL QRSTUVWXYZ ZYXWVUTSRQ JKLMNOPQRSTUVWXYZ Output : 4
1st string from box-1 (ABCDEFGHIJKLMNOP) can be concatenated with any string of box-2 to make a beautiful string; i.e, 3 ways.
2nd string from box-1 (ABCDEFGHIJKL) can be paired concatenated with only the last string of box-2 to make a beautiful string; i.e, 1 way.
Thus the answer is 3 + 1 = 4.
Large I/O files, use faster I/O (scanf, printf for C++)
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.