Find the indices
All submissions for this problem are available.
Abhijeet was new to programming. He was taking C++ classes in his school. One day his teacher introduced him to arrays. One day just to test Abhijeet's understanding of arrays and mathematics his teacher gave him an assignment. Where he was given 3 arrays A, B and C ( 0-based indexing ), not necessarily of same sizes. Now Abhijeet was asked to choose 4 indices from array A such that following conditions are satisfied.
- Suppose the four indices are l1,l2,l3 and l4.
- l1 ≤ l2 and l3 ≤ l4.
- l1 ≤ l3.
- l2 - l1 + 1 is equal to the length of array C.
- l4 - l3 + 1 is equal to the length of array B.
- For l1 ≤ i ≤ l2, A[i] = C[i-l1].
- For l3 ≤ i ≤ l4, A[i] = B[i-l3].
Now teacher was interested in knowing that how many different correct answers Abhijeet can come up with. But as this number can be very large he asked you to write a program for him.
- The first line contains three positive integers, N, K and L, size of the array A, B and C respectively.
- Next line contains N values, elements of array A.
- Next line contains K values, elements of array B.
- Next line contains L values, elements of array C.
- All the arrays are 0-indexed.
Output in a single line the number of different correct answers Abhijeet can give.
Input3 1 1 1 1 1 1 1
Explanation:In the given case different correct answers are: (0,0,0,0),(0,0,1,1),(0,0,2,2),(1,1,2,2),(1,1,1,1),(2,2,2,2).
|Time Limit:||1 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, CLOJ, FS|
Fetching successful submissions