CF405B.Domino Effect
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.

Given the initial directions Chris has pushed the dominoes, find the number of the dominoes left standing vertically at the end of the process!
小 Chris 知道玩多米诺骨牌没什么乐趣,他认为这太随机了,且不需要技巧。于是,他决定用多米诺骨牌来表演一场“多米诺秀”。
Chris 将 n 个多米诺骨牌排成一行,每个骨牌均竖直 upright 放置。初始时,他同时将其中若干骨牌分别向左或向右推倒。然而,在任意两个被推向同一方向的骨牌之间,至少存在一个被推向相反方向的骨牌。
每一秒,每个向左倒下的骨牌会将其左侧相邻的(仍竖直的)骨牌推倒;类似地,每个向右倒下的骨牌会将其右侧相邻的(仍竖直的)骨牌推倒。当一个竖直骨牌同时受到来自左右两侧的倒下骨牌的作用力时,由于受力平衡,它将保持竖直不动。下图展示了一个该过程的可能示例:

给定 Chris 初始推倒骨牌的方向,请你求出:整个过程结束后,仍保持竖直 upright 的骨牌数量!
输入格式
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".
第一行包含一个整数 n(1≤n≤3000),表示排成一行的多米诺骨牌的数量。
第二行包含一个长度为 n 的字符串 s。字符串 s 的第 i 个字符 si 满足:
- 若为
"L",表示第 i 个多米诺骨牌被向左推倒; - 若为
"R",表示第 i 个多米诺骨牌被向右推倒; - 若为
".",表示第 i 个多米诺骨牌尚未被推倒。
保证:若 si=sj="L" 且 i<j,则必存在某个 k 满足 i<k<j 且 sk="R";
若 si=sj="R" 且 i<j,则必存在某个 k 满足 i<k<j 且 sk="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
说明/提示
The first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.
In the second example case, all pieces fall down since the first piece topples all the other pieces.
In the last example case, a single piece has not been pushed in either direction.
第一个示例情况如图所示。仍保持竖直站立的四块积木用橙色高亮标出。
在第二个示例情况中,所有积木均倒下,因为第一块积木推倒了其余所有积木。
在最后一个示例情况中,有一块积木未受到任何方向的推动。
输入解题思路,AI测评打分。不知道怎么写?