Codeforces Round 426 (Div. 2)
B
The Festive Evening
Codeforces
1100
原题
← AC →
翻译中…

image

翻译中…

It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom of Sweetland in case it turns out to reach the wrong hands. So it's a necessity to not let any uninvited guests in.

翻译中…

There are 26 entrances in Jelly Castle, enumerated with uppercase English letters from A to Z. Because of security measures, each guest is known to be assigned an entrance he should enter the castle through. The door of each entrance is opened right before the first guest's arrival and closed right after the arrival of the last guest that should enter the castle through this entrance. No two guests can enter the castle simultaneously.

翻译中…

For an entrance to be protected from possible intrusion, a candy guard should be assigned to it. There are $*k*$ such guards in the castle, so if there are more than $*k*$ opened doors, one of them is going to be left unguarded! Notice that a guard can't leave his post until the door he is assigned to is closed.

翻译中…

Slastyona had a suspicion that there could be uninvited guests at the evening. She knows the order in which the invited guests entered the castle, and wants you to help her check whether there was a moment when more than $*k*$ doors were opened.

翻译中…

Input

翻译中…

Two integers are given in the first string: the number of guests $*n*$ and the number of guards $*k*$ ($1 ≤ *n* ≤ 10^{6}$, $1 ≤ *k* ≤ 26$).

翻译中…

In the second string, $*n*$ uppercase English letters $*s*_{1}*s*_{2}... *s*_{*n*}$ are given, where $*s*_{*i*}$ is the entrance used by the $*i*$-th guest.

翻译中…

Output

翻译中…

Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.

翻译中…

You can output each letter in arbitrary case (upper or lower).

翻译中…

Note

翻译中…

In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the second one is opened.

翻译中…

In the second sample case, the door B is opened before the second guest's arrival, but the only guard can't leave the door A unattended, as there is still one more guest that should enter the castle through this door.

翻译中…

样例

Input #1
5 1
AABBB
Output #1
NO
InputCopy OutputCopy
Input #2
5 1
ABABB
Output #2
YES
InputCopy OutputCopy
题目信息
题号
834B
时间限制
1 s
内存限制
256 MB
标签
数据结构
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。