Substring Search

Limits 1s, 512 MB

You are given nnn strings s1,s2,s3,…,sns_1, s_2, s_3, \ldots, s_ns1​,s2​,s3​,…,sn​ and should process mmm queries. Each query is described by four integers i,l,r,ji,l,r,ji,l,r,j. It means that you need to find how many times substring si[l…r]s_i[l\ldots r]si​[l…r] occurs in sjs_jsj​.


This is a companion discussion topic for the original entry at https://toph.co/p/substring-search