N (1 <= N & n <= 2*10 ^ 6) strings are provided. Each string contains only lowercase English letters and a maximum of five letters. Ask the maximum number of occurrences of the N strings. Enter a single group of inputs. Enter a number N in the first line, and then n rows. Each row contains a string. Output a number to indicate the answer. Sample Input
5abaabbwabaz
Sample output
2
Prompt
# Include <iostream>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <algorithm>
Const int n= 20010;
Using namespace STD;
Struct Node
{
Int flag;
Node * Next [26];
};
Int n, m, ANS = 0;
Struct node * creat ()
{
Node * P = new node;
For (INT I = 0; I <26; I ++)
{
P-> next [I] = NULL;
}
P-> flag = 0;
Return P;
}
Void insert (node * root, char * B)
{
Int num;
Int Len = strlen (B );
Node * P = root;
For (INT I = 0; I <Len; I ++)
{
Num = B [I]-'A ';
If (p-> next [num] = NULL)
{
P-> next [num] = creat ();
}
P = p-> next [num];
}
P-> flag ++;
If (p-> flag> ans)
Ans = p-> flag;
}
Void free (struct node * root)
{
For (INT I = 0; I <n; I ++)
{
If (root-> next [I]! = NULL)
{
Free (root-> next [I]);
}
}
Free (Root );
}
Int main ()
{
Char a [n] [50], s [50];
Node * P;
Scanf ("% d", & M );
P = creat ();
For (INT I = 0; I <m; I ++)
{
Scanf ("% s", S );
Insert (P, S );
}
Printf ("% d \ n", ANS );
Free (P );
Return 0;
}