This is a problem from codeforces round 344 div2:

http://codeforces.com/contest/631/problem/D

Basically it asks to find the number of occurrences of string S in string T but the strings are given in following format:

One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Ex:aabbc will be represented as 2-a 2-b 1-c

The total no. of blocks are ≤ 200 000 and li (as described above) is <=1000000.

Can anyone give me the idea to solve it using Rabin Karp algorithm?