Magic Set of Strings

3.5

4 votes
Problem

There is a string named base_string. A sequence of m strings a1,a2,..,ak is called magic sequence, if when these strings are added, the resultant come out to be base_string ( a1 + a2 + ... + ak = base_string ), and the first characters of these strings are distinct.

Determine whether such a magic sequence exists or not.

Input

The first line contains a positive integer m — the number of strings that should be in a magic sequence. Given : 1 ≤ m ≤ 26

The second line contains string base_string, consisting of lowercase alphabet. The length of the string is within range from 1 to 100, inclusive.

Output

If such sequence doesn't exist, then print in a single line "NO" (without the quotes). Otherwise, print "YES" (without the quotes)

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

The magic string can be "aaa" or "cas".

There are two possible answers : {"aaaca", "s"} and {"aaa", "cas"}.

Editor Image

?