BZOJ 3097: Hash Killer I

3097: Hash Killer I

Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special Judge
[Submit][Status][Discuss]

Description

The weather was good that day, hzhwcmhf Shenben gave VFleaKing a question:
Given a string S of length N, how many different substrings of length L are there.
A substring is defined as a continuous segment of S[l], S[l + 1], ... S[r].
Two strings are considered to be different if and only if the characters in a certain position are different.

At first glance, VFleaKing thinks that this is not Hash's naked question! So decisively wrote hash + sort.
And hzhwcmhf Shenben naturally knows in his heart that this question is the number of < L in the height of the suffix array + 1, which is the number of nodes whose length interval represented by the suffix automaton contains L, which is the number of nodes whose depth is L in the suffix tree. quantity.
But hzhwcmhf Shenben looked at VFleaKing's practice and said he was very sweaty. So I wanted to get rid of him.

VFleaKing uses a lexicographic hash, and its code is roughly as follows:
u64 val = 0;
for (int i = 0; i < l; i++)
 val = val * base + s[i] - 'a';
u64 is None Notation int64, range is [0, 2^64). VFleaKing lets val overflow naturally.
base is a constant, VFleaKing will determine its value according to the mood.
VFleaKing also finds base ^ l, that is, the l power of base, so that the hash value of all substrings of length L can be easily found.
Then VFleaKing sorts the hash values, removes duplicates, finds how many different hash values ​​there are, and uses this number as the result.
The C++ code of its algorithm is as follows:

typedef unsigned long long u64;

 

const int MaxN = 100000;

 

inline int hash_handle(const char *s, const int &n, const int &l, const int &base)
{
 u64 hash_pow_l = 1;
 for (int i = 1; i <= l; i++)
  hash_pow_l *= base;

 

 int li_n = 0;
 static u64 li[MaxN];

 

 u64 val = 0;
 for (int i = 0; i < l; i++)
  val = val * base + s[i] - 'a';
 li[li_n++] = val;
 for (int i = l; i < n; i++)
 {
  val = val * base + s[i] - 'a';
  val -= (s[i - l] - 'a') * hash_pow_l;
  li[li_n++] = val;
 }

 

 sort (li, li + li_n);
 li_n = unique (li, li + li_n) - li;
 return li_n;
}

Of course hzhwcmhf knows how to get stuck! But he wants to test you.

 

Input

 

No input.

 

Output

 

You need to output a set of data to make the VFleaKing code WA out. We will use Special Judge to check the correctness of your results.
The output file consists of two lines.
The first line contains two numbers n and l separated by spaces.
The second line is a string of length n. Can only contain 'a'~'z'.
It is necessary to ensure that 1 <= n <= 10^5, 1 <= l <= n,
if it does not meet the above format, it will be WA.
Do not have extra characters, it is likely to cause you WA.

 

Sample Input

no

Sample Output

8 4
buaabuaa
(当然这个输出是会WA的)

HINT

orz 波兰人 & fotile96 & sillycross

Source

VFleaKing & hzhwcmhf

 

题目链接

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324793509&siteId=291194637