6.10 VJ H - Frog Jumps
#include<bits/stdc++.h>
#define ll long long
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll nl=1e18;
/*青蛙过河
题意:青蛙每个位置标有L,R表示青蛙只能向左和向右跳,每次最多能跳m个长度,求m的最小值
只要不跳到L上就可以了,因为如果跳到L还要往回跳,然后还要跳过包含L的这段距离
因此只要求L的最大连续长度,最后输出加1就可以了
*/
int main()
{
speed_up;
int n;
cin>>n;
while(n--)
{
string s;
cin>>s;
int p=0,maxx=0;
for(int i=0;i<s.length();i++)
{
if(s[i]=='L'){
p++;
maxx=max(maxx,p);
}
if(s[i]=='R')p=0;
}
cout<<maxx+1<<endl;
}
#define ll long long
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll nl=1e18;
/*青蛙过河
题意:青蛙每个位置标有L,R表示青蛙只能向左和向右跳,每次最多能跳m个长度,求m的最小值
只要不跳到L上就可以了,因为如果跳到L还要往回跳,然后还要跳过包含L的这段距离
因此只要求L的最大连续长度,最后输出加1就可以了
*/
int main()
{
speed_up;
int n;
cin>>n;
while(n--)
{
string s;
cin>>s;
int p=0,maxx=0;
for(int i=0;i<s.length();i++)
{
if(s[i]=='L'){
p++;
maxx=max(maxx,p);
}
if(s[i]=='R')p=0;
}
cout<<maxx+1<<endl;
}
}

浙公网安备 33010602011771号