302129: CF405B. Domino Effect
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Domino Effect
题意翻译
### 题目描述 小克里斯认为**简单地推倒**多米诺骨牌没有意思,他认为这太随意了,不需要技巧。因此,他决定玩~~一种他歪歪出来的~~多米诺骨牌游戏并进行“多米诺骨牌表演”。 克里斯把 $n$ 张多米诺骨牌排在一条线上,垂直竖立。一开始,他**同时**将一些多米诺骨牌推向左侧或右侧,并且保证,在每两个多米诺骨牌推向相同方向之间的某个地方,至少有一个多米诺骨牌被推向相反的方向。 每一秒,每个倒在左边的多米诺骨牌将会推动左边相邻的多米诺骨牌。同样地,向右倾斜的多米诺骨牌将会推动右边相邻的多米诺骨牌。当一个垂直的多米诺骨牌有从两边落下的多米诺骨牌时,由于力量的平衡而保持不变。以下这张图(包括3个例子)显示了该过程的一个可能示例。 ![](https://cdn.luogu.org/upload/vjudge_pic/CF405B/37fecb2c12dba94b96d336756a84bf7894c6655a.png) 给出克里斯推动多米诺骨牌的最初方向,请编程找到在过程结束时垂直留下的多米诺骨牌的数量。 ### 输入输出格式 #### 输入格式: 第一行包含一个整数 $ n( 1 \leq N \leq 3000 )$,表示多米诺骨牌的数量。下一行包含一个字符串 (长度为 $n$)。该字符串的第 $i$ 个字符有以下几种可能: ``` 'L' : 如果第 i 个多米诺骨牌开始时被推到左边; 'R' : 如果第 i 个多米诺骨牌开始时被推到右边; '.' : 如果第 i 个多米诺骨牌一开始没被推动。 ``` 保证如果 $S_{i} = S_{j} = $ ``'L'`` $(i < j)$ ,存在这样的 ķ 使得 $ i < k < j $ 且 $S_ {k}=$ ``'R'`` ; 保证如果 $S_{i} = S_{j} = $ ``'R'`` $(i < j)$ ,存在这样的 ķ 使得 $ i < k < j $ 且 $S_ {k}=$ ``'L'`` ; #### 输出格式: 输出一个整数,即在结束时保持垂直的多米诺骨牌的数量。题目描述
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show". Chris arranges $ n $ dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes either to the left or to the right. However, somewhere between every two dominoes pushed in the same direction there is at least one domino pushed in the opposite direction. After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces. The figure shows one possible example of the process. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF405B/37fecb2c12dba94b96d336756a84bf7894c6655a.png)Given the initial directions Chris has pushed the dominoes, find the number of the dominoes left standing vertically at the end of the process!输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=3000 $ ), the number of the dominoes in the line. The next line contains a character string $ s $ of length $ n $ . The $ i $ -th character of the string $ s_{i} $ is equal to - "L", if the $ i $ -th domino has been pushed to the left; - "R", if the $ i $ -th domino has been pushed to the right; - ".", if the $ i $ -th domino has not been pushed. It is guaranteed that if $ s_{i}=s_{j}= $ "L" and $ i<j $ , then there exists such $ k $ that $ i<k<j $ and $ s_{k}= $ "R"; if $ s_{i}=s_{j}= $ "R" and $ i<j $ , then there exists such $ k $ that $ i<k<j $ and $ s_{k}= $ "L".
输出格式
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
输入输出样例
输入样例 #1
14
.L.R...LR..L..
输出样例 #1
4
输入样例 #2
5
R....
输出样例 #2
0
输入样例 #3
1
.
输出样例 #3
1