#abc311a. A - First ABC
A - First ABC
Score : points
问题陈述
给定一个包含 A、B 和 C 的字符串 。保证 中包含所有 A、B 和 C。
如果从左到右逐个检查 的字符,那么在首次满足以下条件时,需要检查多少个字符?
A、B和C至少各出现一次。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string consisting of A, B, and C. is guaranteed to contain all of A, B, and C.
If the characters of are checked one by one from the left, how many characters will have been checked when the following condition is satisfied for the first time?
- All of
A,B, andChave appeared at least once.
Constraints
- is a string of length consisting of
A,B, andC. - contains all of
A,B, andC.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5
ACABB
Sample Output 1
4
In the first four characters from the left, A, B, and C appear twice, once, and once, respectively, satisfying the condition.
The condition is not satisfied by checking three or fewer characters, so the answer is .
Sample Input 2
4
CABC
Sample Output 2
3
In the first three characters from the left, each of A, B, and C appears once, satisfying the condition.
Sample Input 3
30
AABABBBABABBABABCABACAABCBACCA
Sample Output 3
17
update @ 2024/3/10 08:49:57