There is a frog staying to the left of the string s=s1s2…sn consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either ‘L’ or ‘R’. It means that if the frog is staying at the i-th cell and the i-th character is ‘L’, the frog can jump only to the left. If the frog is staying at the i-th cell and the i-th character is ‘R’, the frog can jump only to the right. The frog can jump only to the right from the cell 0.

Note that the frog can jump into the same cell twice and can perform as many jumps as it needs.

The frog wants to reach the n+1-th cell. The frog chooses some positive integer value d before the first jump (and cannot change it later) and jumps by no more than d cells at once. I.e. if the i-th character is ‘L’ then the frog can jump to any cell in a range [max(0,i−d);i−1], and if the i-th character is ‘R’ then the frog can jump to any cell in a range [i+1;min(n+1;i+d)].

The frog doesn’t want to jump far, so your task is to find the minimum possible value of d such that the frog can reach the cell n+1 from the cell 0 if it can jump by no more than d cells at once. It is guaranteed that it is always possible to reach n+1 from 0.

You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤104) — the number of test cases.

The next t lines describe test cases. The i-th test case is described as a string s consisting of at least 1 and at most 2⋅105 characters ‘L’ and ‘R’.

It is guaranteed that the sum of lengths of strings over all test cases does not exceed 2⋅105 (∑|s|≤2⋅105).

Output
For each test case, print the answer — the minimum possible value of d such that the frog can reach the cell n+1 from the cell 0 if it jumps by no more than d at once.

Example
Input
6
LRLRRLL
L
LLR
RRRR
LLLLLL
R
Output
3
2
3
1
7
1
Note
The picture describing the first test case of the example and one of the possible answers:

In the second test case of the example, the frog can only jump directly from 0 to n+1.

In the third test case of the example, the frog can choose d=3, jump to the cell 3 from the cell 0 and then to the cell 4 from the cell 3.

In the fourth test case of the example, the frog can choose d=1 and jump 5 times to the right.

In the fifth test case of the example, the frog can only jump directly from 0 to n+1.

The picture describing the first test case of the example and one of the possible answers:

In the second test case of the example, the frog can only jump directly from 00 to n+1n+1.

In the third test case of the example, the frog can choose d=3d=3, jump to the cell 33 from the cell 00 and then to the cell 44 from the cell 33.

In the fourth test case of the example, the frog can choose d=1d=1 and jump 55 times to the right.

In the fifth test case of the example, the frog can only jump directly from 00 to n+1n+1.

In the sixth test case of the example, the frog can choose d=1d=1 and jump 22 times to the right.

这个题可以看作为在一个字符串中相邻的两个L之间最远的距离是多少,如果能看到这里代码也就比较好写了,但是当时没看出来

#include<iostream>
#include<cstring>
const long long maxn=2e5+;
char s[maxn];
using namespace std;
int main(){
int t,d,x;
cin>>t;
while(t--){
d=,x=; //每次操作时对这两个数进行重制
cin>>s;
int l=strlen(s);
for(int i=;i<l;i++){
if(s[i]=='R'){
x=;
}
else{
x++;
if(x>d) d=x;
}
}
cout<<d+<<endl;
}
}

最新文章

  1. PowerShell自动部署IIS站点(Windows Server 2008 R2)
  2. Struts2 contentType属性列表
  3. iOS开发UI篇—懒加载
  4. Hibernate和Jpa的关系
  5. SSRS 的简单使用(二)
  6. Android Volley入门到精通:定制自己的Request
  7. 没有好看的 Terminal 怎么能够快乐地写代码
  8. ORGANIZATION
  9. strcpy
  10. MyBatis学习总结_10_批量操作
  11. 第三百五十一天 how can I 坚持
  12. spring aop expression简单说明
  13. 20 个最棒的 jQuery Tab 插件
  14. java ,js获取web工程路径
  15. clock_gettime测代码运行时间
  16. 远程推送,集成极光的SDK,证书制造
  17. 如何用cocoapods 来管理项目中的第三方框架?
  18. 【Win 10 应用开发】UI Composition 札记(二):基本构件
  19. MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法
  20. map和flatmap的区别+理解、学习与使用 Java 中的 Optional

热门文章

  1. Python---3基础输入方法
  2. 周鸿祎身价超过刘强东,A股上市的360能让周鸿祎成为中国首富吗?
  3. 教你win7关闭开机动画,大幅度加快开机时间
  4. BTCU(高校区块链联盟)-联盟链第6讲作业
  5. ZeroMQ,史上最快的消息队列
  6. C++走向远洋——30(六周,项目一1.0)
  7. tomcat服务器的应用总结
  8. Python中的BeautifulSoup库简要总结
  9. Rust入坑指南:智能指针
  10. 4,Java中的多线程