I need help with this problem!!!
Разница между en1 и en2, 91 символ(ов) изменены
Hi guys, as the title stated, I really need your help with this problem↵

You have a set. Initially the set is empty.↵
Given Q queries
 (Q <= 10^5) , there are two types of queries:↵

1 s : s is a string, add s to the set. If the set already contains s, do nothing↵

2 S : For all string k that belong to the set, calculate the sum of D(k) * length(k), D(k) is the number of occurrences of k in S↵
as a substring (example, aa is a substring of aabc, ac is not a substring of aabc) and length(k) is length of k↵

It is guaranteed that the sum of length of these strings don't exceed 10^5↵

Example :↵

Q = 5↵

1 aa↵

2 aa↵

1 aa↵

1 ab↵

2 ababaa↵

-> output : 2 , 6↵

Note: After the first query, the set is {aa}, hence the answer for the second query is 2↵

After the fourth query, the set is {aa,ab} -> ababaa = 6 because ab appears twice, aa appear once : 2*2 + 2*1 = 6

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский desperateboy12344 2024-09-06 16:04:47 91
en1 Английский desperateboy12344 2024-09-06 16:03:41 826 Initial revision (published)