CF265A.Colorful Stones (Simplified Edition)
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the color of the corresponding stone is red, green, or blue, respectively.
Initially Squirrel Liss is standing on the first stone. You perform instructions one or more times.
Each instruction is one of the three types: "RED", "GREEN", or "BLUE". After an instruction c, if Liss is standing on a stone whose colors is c, Liss will move one stone forward, else she will not move.
You are given a string t. The number of instructions is equal to the length of t, and the i-th character of t represents the i-th instruction.
Calculate the final position of Liss (the number of the stone she is going to stand on in the end) after performing all the instructions, and print its 1-based position. It is guaranteed that Liss don't move out of the sequence.
有一串彩色的石头。每块石头的颜色为红色、绿色或蓝色中的一种。给你一个字符串 s。s 的第 i 个字符(从 1 开始计数)表示第 i 块石头的颜色。若该字符为 "R"、"G" 或 "B",则对应石头的颜色分别为红色、绿色或蓝色。
初始时,松鼠 Liss 站在第一块石头上。你需要执行一条或多条指令。
每条指令为以下三种类型之一:"RED"、"GREEN" 或 "BLUE"。执行指令 c 后,若 Liss 当前所站石头的颜色恰好为 c,则她向前移动一块石头;否则她不移动。
给你一个字符串 t。指令的总数量等于 t 的长度,且 t 的第 i 个字符表示第 i 条指令。
请计算 Liss 执行完所有指令后的最终位置(即她最后所站石头的编号),并输出其从 1 开始计数的位置。题目保证 Liss 不会移出石头序列。
输入格式
The input contains two lines. The first line contains the string s (1 ≤ |s| ≤ 50). The second line contains the string t (1 ≤ |t| ≤ 50). The characters of each string will be one of "R", "G", or "B". It is guaranteed that Liss don't move out of the sequence.
输入包含两行。第一行包含字符串 s(1 ≤ ∣s∣ ≤ 50)。第二行包含字符串 t(1 ≤ ∣t∣ ≤ 50)。每个字符串中的字符均为 "R"、"G" 或 "B" 之一。保证 Liss 不会移出序列。
输出格式
Print the final 1-based position of Liss in a single line.
在一行中输出莉丝最终的从 1 开始计数的位置。
输入输出样例
输入#1
RGB RRR
输出#1
2
输入#2
RRRBGBRBBB BBBRR
输出#2
3
输入#3
BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB BBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB
输出#3
15
输入解题思路,AI测评打分。不知道怎么写?