Ask a string problem
Difference between en1 and en2, changed 7 character(s)
Given three integers p, q, r.↵
Then provide p strings, q strings, and r strings.↵
Find the number of string pairs (AB) that satisfy:↵

A is a prefix of some string in the p strings;↵

B is a suffix of some string in the q strings;↵

The concatenated string AB of A and B is a substring of some string in the r strings.↵
p, q, r are all less than or equal to 300,000, and the total length of the p strings is less than or equal to 300,000, the total length of the q strings is less than or equal to 300,000, and the total length of the r strings is less than or equal to 300,000.↵
Please provide an implementation that runs within 3 seconds and uses no more than 1GB of memory to solve this problem.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Exotic_sum 2025-02-23 14:47:51 7
en1 English Exotic_sum 2025-02-23 14:39:40 714 Initial revision (published)