CF264D.Colorful Stones
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are two sequences of colorful stones. The color of each stone is one of red, green, or blue. You are given two strings s and t. The i-th (1-based) character of s represents the color of the i-th stone of the first sequence. Similarly, the i-th (1-based) character of t represents the color of the i-th stone of the second sequence. 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 of the first sequence and Cat Vasya is standing on the first stone of the second sequence. You can perform the following instructions zero or more times.
Each instruction is one of the three types: "RED", "GREEN", or "BLUE". After an instruction c, the animals standing on stones whose colors are c will move one stone forward. For example, if you perform an instruction «RED», the animals standing on red stones will move one stone forward. You are not allowed to perform instructions that lead some animals out of the sequences. In other words, if some animals are standing on the last stones, you can't perform the instructions of the colors of those stones.
A pair of positions (position of Liss, position of Vasya) is called a state. A state is called reachable if the state is reachable by performing instructions zero or more times from the initial state (1, 1). Calculate the number of distinct reachable states.
有两列彩色石子。每个石子的颜色为红色(red)、绿色(green)或蓝色(blue)中的一种。给定两个字符串 s 和 t。s 的第 i 个字符(按 1-起始索引)表示第一列中第 i 个石子的颜色;类似地,t 的第 i 个字符(按 1-起始索引)表示第二列中第 i 个石子的颜色。若该字符为 "R"、"G" 或 "B",则对应石子的颜色分别为红色、绿色或蓝色。
初始时,松鼠 Liss 站在第一列的第一个石子上,猫 Vasya 站在第二列的第一个石子上。你可以执行以下三种指令中的任意一种,执行次数可以为零次或多次。
每条指令是以下三种类型之一:"RED"、"GREEN" 或 "BLUE"。执行指令 c 后,所有站在颜色为 c 的石子上的动物将向前移动一个石子。例如,若执行指令 "RED",则所有站在红色石子上的动物将向前移动一个石子。你不得执行会导致任一动物移出序列的指令。换言之,若某些动物已站在各自序列的最后一个石子上,则你不能执行与这些石子颜色相同的指令。
将一对位置(Liss 所在位置,Vasya 所在位置)称为一个状态。若某个状态能从初始状态 (1,1) 出发、通过零次或多次指令到达,则称该状态为可达状态。请计算不同的可达状态的总数。
输入格式
The input contains two lines. The first line contains the string s (1 ≤ |s| ≤ 106). The second line contains the string t (1 ≤ |t| ≤ 106). The characters of each string will be one of "R", "G", or "B".
输入包含两行。第一行包含字符串 s(1 ≤ ∣s∣ ≤ 106)。第二行包含字符串 t(1 ≤ ∣t∣ ≤ 106)。每个字符串的字符均为 "R"、"G" 或 "B" 之一。
输出格式
Print the number of distinct reachable states in a single line.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
输出可达的不同状态的数量,仅一行。
请注意,在 C++ 中不要使用 %lld 说明符来读写 64 位整数。推荐使用 cin、cout 流,或 %I64d 说明符。
输入输出样例
输入#1
RBR RGG
输出#1
5
输入#2
RGBB BRRBRR
输出#2
19
输入#3
RRRRRRRRRR RRRRRRRR
输出#3
8
说明/提示
In the first example, there are five reachable states: (1, 1), (2, 2), (2, 3), (3, 2), and (3, 3). For example, the state (3, 3) is reachable because if you perform instructions "RED", "GREEN", and "BLUE" in this order from the initial state, the state will be (3, 3). The following picture shows how the instructions work in this case.

在第一个例子中,共有五个可达状态:(1,1)、(2,2)、(2,3)、(3,2) 和 (3,3)。例如,状态 (3,3) 是可达的,因为若从初始状态依次执行指令 “RED”、“GREEN” 和 “BLUE”,最终状态即为 (3,3)。下图展示了本例中各指令的作用方式。

输入解题思路,AI测评打分。不知道怎么写?