Type: Default 1000ms 256MiB

ABC字符串

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

说明

你有一个字符串SS,它只由大写字母A,B,CA,B,C构成。现在需要你从字符串左边开始取这个字符串的一个连续子串,使得这个子串中,A,B,CA,B,C三个字母都有出现。求出这个子串的最小长度。

输入输出

输入

第一行为字符串长度NN,第二行是这个字符串SS

输出

满足题目要求的子串的最小长度。

样例

5
ABACA
4

样例解释

样例中,若子串长度为1,则取出的子串为"A",不符合条件;

若子串长度为2,则取出的子串为"AB",不符合条件;

若子串长度为3,则取出的子串为"ABA",不符合条件;

若子串长度为4,则取出的子串为"ABAC",满足子串中A,B,C都出现的条件,因此答案为4。

Limitation

100%100\%的数据,3N1003≤N≤100

2023暑假语法组测试

Not Attended
Status
Done
Rule
IOI
Problem
8
Start at
2023-8-17 8:30
End at
2023-8-17 11:30
Duration
3 hour(s)
Host
Partic.
32