A8784 | Colorful Stones (Simplified Edition)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
输出格式
Print the final 1-based position of Liss in a single line.
输入输出样例
输入 #1
RGB RRR
输出 #1
2
输入 #2
RRRBGBRBBB BBBRR
输出 #2
3
输入 #3
BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB BBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB
输出 #3
15
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted