Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly by preprocessing the string s. But now he wants to make it harder. So he wants to ask "how many consecutive substrings of s…
C. Cyclical Quest time limit per test:3 seconds memory limit per test:512 megabytes input:standard input output: standard output Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly…
#include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; ; const int inf = 0x3f3f3f3f; c…
E. Little Elephant and Strings time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves strings very much. He has an array a from n strings, consisting of lowercase Englis…
You are given n strings ti. Each string has cost ci. Let's define the function of string , where ps, i is the number of occurrences of s in ti, |s| is the length of the string s. Find the maximal value of function f(s) over all strings. Note that the…