[Atc322A] First ABC 2
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Statement
You are given a string S of length N consisting of the characters A, B, and C. Your task is to find the position where the substring "ABC" first appears in S. In other words, find the smallest integer n that satisfies the following conditions:
- The substring from the -th character to the -th character of
Sis "ABC".
If "ABC" does not appear in S, print -1.
Input
The input consists of:
- An integer
N— the length of the stringS. - A string
Sof lengthNconsisting of the charactersA,B, andC.
Output
Print the position where the substring "ABC" first appears in S, or -1 if it does not appear.
Examples
Example 1
8
ABABCABC
3
ABC first appears in at the -rd through -th characters of . Therefore, the answer is .
Example 2
3
ACB
-1
If ABC does not appear in , print .
Example 3
20
BBAAABBACAACABCBABAB
13
Programming exercise on 13 August
- 状态
- 已结束
- 规则
- IOI
- 题目
- 3
- 开始于
- 2024-8-13 16:30
- 结束于
- 2024-8-13 18:30
- 持续时间
- 2 小时
- 主持人
- 参赛人数
- 3