Hi all,

I've recently come across this http://main.edu.pl/en/archive/pa/2010/fra. The problem statement is as follow: given up to *n* = 5000 disjoint intervals of the form [*a* _{ i}, *b* _{ i}], we let *S* be all the integers in these intervals ( *a* _{1}, *a* _{1} + 1, ..., *b* _{1}, *a* _{2}, ..., *b* _{2}, .., *b* _{ n} Now, we have up to *q* = 500000 queries of strings, count the total number of times a string *s* will appear in the numbers of set *S*.

The only thing I can solve is if *n* = 1 or something, and I barely can see a way to approach this problem, especially since we can't iterate through all the intervals for each query.

If somebody could help, that would be great!

Best,

minimario