prompt
string
response
string
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
T = int(input()) for t in range(T): s = input() x = 0 p = -1 for j in range(len(s)): if s[j]=="R" and j-p>=x: x = j-p if s[j]=="R": p = j if len(s)-p>x: x = len(s)-p print(x)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for t in range(int(input())): s = input() x = [-1] + [i for i in range(len(s)) if s[i] == 'R'] + [len(s)] print(max([x[i+1] - x[i] for i in range(len(x) - 1)]))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; long long n = s.size(); s = "." + s; s += "W"; long long l = 0, r = n + 1, ans = n + 1; while (l <= r) { long long mid = (l + r) >> 1; bool pos = false; long long cp = 0; while (cp != n + 1) { long long ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; import java.io.*; public class C627 { public static void main(String [] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); while ( t > 0) { String s = sc.next(); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for T in range(t): s=input() m=0; cur=-1 for i in range(len(s)): if(s[i]=='R'): if(i-cur>m): m=i-cur cur=i if(m==0): print(len(s)+1) else: print(max(m,len(s)-cur))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
a=int(input()) for i in range(a): b=input() c=len(b) d=0 e=0 for j in range(c): if b[j]=="R": e=0 else: e=e+1 if e>d: d=e print(d+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def solve(): s = input().strip() result = max(le...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for i in range(t): s=input().split("R") a=[] for i in range(len(s)): a.append(len(s[i])) print(max(a)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for qwe in range(t): # s = f.readline()[:-1] s = input() s += "R" ans = 0 k = 0 for i in range(len(s)): if s[i] == "L": k += 1 elif s[i] == "R": ans = max(k, ans) k = 0 print...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.io.*; import java.util.*; public class Q1 { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); while (t-- > 0) { String str=in.next(); int N =str....
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int sum = 0, k = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { sum = max(sum, i + 1 - k); k = i + 1; } } int l = s.size(); sum = max(su...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
T=int(input()) for x in range(T): string=['R'] y=input() s=1 for z in y: string.append(z) s=s+1 string.append('R') s=s+1 #print(s) temp=0 diff=0 for a in range(1,s): if(string[a]=='R'): if(a-diff>temp): temp=a-diff ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { string s; cin >> s; s += 'R'; vector<long long> v; v.push_back(0); for (long long i = 0; i < s.size(); i++) { if (s[i] =...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
a = int(input()) for k in range(a): b = input() t = len(b) if b.count('L') == t: print(t + 1) elif b.count('R') == t: print(1) else: max1 = 0 f = 0 for i in range(t): if b[i] == 'L': f += 1 else: if max1 ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for _ in range(t): s=input() mx=0;c=0 for i in range(len(s)): if s[i]=='L': c+=1 else: mx=max(mx,c) c=0 mx=max(mx,c) print(mx+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def frog(S): n = len(S) r = 0 l = -1 ans = 0 while r < n: while r < n and S[r] != 'R': r += 1 ans = max(ans, r - l) l = r r += 1 return min(ans, n + 1) t = int(input()) for _ in range(t): print(frog(input()))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
a=int(input()) for p in range(a): flag=0 h=0 c=input() b=len(c) for i in range(b): if c[i]=='L': flag=flag+1 else: if flag>=h: h=flag flag=0 print(max((h+1),(flag+1)))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; void solve() { int t; string s; cin >> t; while (t--) { int mx = -1, temp = 0; cin >> s; s = 'R' + s + 'R'; for (auto c : s) { temp++; if (c == 'R') { mx = max(mx, temp); temp = 0; } } cout << mx << "\n"; }...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s=input() n1=len(s) s='R'+s+'R' n=len(s) l=[] for i in range(n): if(s[i]=='R'): l.append(i) if(len(l)==2): print(n1+1) else: c=0 for i in range(1,len(l)): if(l[i]-l[i-1]>c): c=l[i]-l[i-1] print(c)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
from math import factorial from collections import Counter, defaultdict from heapq import heapify, heappop, heappush import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.bu...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) while(t): s = input() cur = 0 tot = 0 for i in range(0, len(s)): if s[i] == 'R': if cur > tot: tot = cur cur = 0 else: cur += 1 if cur > tot: tot = cur print(tot + 1) t -= 1
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; import java.lang.*; import java.io.*; public class Main { /* HashMap<> map=new HashMap<>(); TreeMap<> map=new TreeMap<>(); map.put(p,map.getOrDefault(p,0)+1); for(Map.Entry<> mx:map.entrySet()){ int v=mx.getValue(),k=mx.getKey(); }for (int i = 1; i <= 1000; i++) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class C627_C { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for i in range(t): IN = input() crt = 0 ms = 0 for x in IN: if x == "L": crt+=1 else: if crt > ms: ms = crt crt = 0 if crt > ms: ms = crt print(ms+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int n, m(0), r; string s; cin >> n; for (int j = 1; j <= n; j++) { cin >> s; for (int i = 0; i <= s.size(); i++) if (s[i] == 'L') { m++; } else { r = max(r, m); m = 0; } cout << r + 1 << endl; r ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for i in range(t): s = input() c = 1 mc = 1 flag = True if s[0] == "L": c += 1 mc += 1 if len(s) > 1: for j in range(1, len(s)): if s[j] == "L": c += 1 if c > mc: mc = c elif s[j] == "R": c = 1 print(mc)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1 << 29; const long long MAX_N = 1e6 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { string s; cin >> s; int n = s.length(); vector<int> r; r...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import math class Read: @staticmethod def string(): return input() @staticmethod def int(): return int(input()) @staticmethod def list(sep=' '): return input().split(sep) @staticmethod def list_int(sep=' '): return list(map(int, input().split(sep...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
T = int(input()) for t in range(T): s = input() s = 'R'+s+'R' maxd = 0 last = 0 for i in range(1,len(s)): if(s[i]=='R'): if(i-last>maxd): maxd=i-last last = i print(maxd)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; public class Frog { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int i=0,j=0,z=0,n=0,max=0,l=0; char c = ' '; int ans[] = new int[t]; while(z<t) { String s = sc.next(); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import collections import sys;input=sys.stdin.readline L='' def f(d): i=0 n=len(L) while True: for j in range(d,0,-1): if i+j>=n+1: return True if L[i+j-1]=='R': i=i+j break else: break return False for _...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
test_cases = int(input()) test = test_cases data = [] while test_cases > 0: data.append(input()) test_cases -= 1 for i in range(0, test): dummy = [0] for j in range(0, len(data[i])): if data[i][j] == "R": dummy.append(j + 1) dummy.append(len(data[i])+1) ans = 0 for k in ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for _ in range(t): s=input() ma=0 c=0 for i in range(len(s)-1,-1,-1): if s[i]=='L': c+=1 else: c=0 ma=max(ma,c) print(ma+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import sys input = sys.stdin.readline def main(): for _ in range(int(input())): s = input() dist = 1 t = 1 for i in range(len(s)): if s[i] == "L": t += 1 else: dist = max(t, dist) t = 1 dist = m...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): st = str(input()) li = max(map(len,st.split('R'))) print(li+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
from sys import stdin def get_int_input(): return int(stdin.readline()) def get_str_input(): return input() def multiple_input(): return map(int, stdin.readline().split()) def list_input(): return list(map(int, stdin.readline().split())) t = get_int_input() while t: t-=1 s = get_str_input() if all(e=='R' ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for _ in range(t): arr = [x for x in input()] arr = ['R'] + arr arr.append('R') brr = [] difference = [] for i in range(len(arr)): if arr[i] == 'R': brr.append(i) for i in range(len(brr)-1): difference.append(brr[i+1] - brr[i]) if len(difference) > 0: print(max(difference)) else: pr...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def max_jump(steps): #rs = [] max_step = 0 lists = [0] pointer = 0 for i in steps: lists.append(i) lists.append(1) for i in range(len(lists)): if lists[i]=='R' or lists[i]==1: if i-pointer>max_step: max_step = i-pointer pointer = i return ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def solve(s): count, d = 1, 0 i = 0 while i < len(s): if s[i] != 'R': count += 1 else: if count > d: d = count count = 1 i += 1 if count > d: d = count return d t = int(input()) for i in range(t): s = in...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#optimal is to jump to every R t=int(input()) for _ in range(t): s=input() s='R'+s+'R' maxGap=0 gap=1 for c in s: if c=='R': maxGap=max(maxGap,gap) gap=1 else: gap+=1 print(maxGap)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) while t> 0: seq = input() c=0 d=0 for val in seq: if val == 'L': c+=1 else: d = max(c,d) c=0 d = max(c,d) d+=1 print(d) t-=1
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for t in range(int(input())): arr=list(input()) if arr.count("R")==0: print(len((arr))+1) elif arr.count("R")==len(arr): print(1) else: pos=[0,len(arr)+1] for i in range(len(arr)): ele=arr[i] if ele=="R": pos.append(i+1) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s=input() ctr,ctr2=1,0 for i in range(len(s)): if s[i]=='L': ctr+=1 else: ctr2=max(ctr2,ctr) ctr=1 if s[-1]=='L': ctr2=max(ctr2,ctr) print(ctr2)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): st = input() arr = [0] for i in range(len(st)): if st[i] == 'R': arr.append(i+1) arr.append(len(st)+1) maxdiff = 0 for j in range(len(arr)-1): diff = arr[j+1] - arr[j] maxdiff = diff if diff > maxdiff else maxdiff print(maxdiff)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): a=input() arr=[] for i in range(len(a)): if a[i]=='R': arr.append(i+1) arr.append(len(a)+1) #print(arr) ans=min(arr) if len(arr)==1: print(arr[0]) else: for i in range(len(arr)-1): ans=max(ans,arr[i+1]-arr[i]) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.ArrayList; import java.util.Scanner; public class que3 { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int test = scn.nextInt(); StringBuilder sb=new StringBuilder(); while (test-- > 0) { String s = scn.next(); int max = s.length() + 1; int min = 1; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string p; while (t--) { int c = 0, r = 0; cin >> p; for (int i = 0; i < p.length(); i++) { if (p[i] == 'L') { c++; r = max(c, r); } else c = 0; } cout << r + 1 << endl; } }
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
n = int(raw_input()) for i in range(n): jumps = raw_input() l = 0 r = 1 count = 1 while(l < len(jumps) and r < len(jumps)): if jumps[l] != jumps[r]: if jumps[l] == "L": count = max(count, 1+r-l) l = r r+=1 if jumps[l] == "L": count = max(count, 1+r-l) print(count) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def main(): t = int(input()) for i in range(0, t): solve() def solve(): s = input() maior, atual = 0, 0 for i in s: if i == 'L': atual += 1 else: maior = max(maior, atual) atual = 0 print(max(maior, atual) + 1) main()
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for i in range(t): s = input() l = [0] for i in range(len(s)): if s[i] == "R": l.append(i+1) l.append(len(s)+1) z = float("-inf") for j in range(1,len(l)): z = max(l[j]-l[j-1],z) print(z)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.*; import java.util.*; public class FrogJumps{ static Scanner sc = new Scanner(System.in); static void frogJumps(){ String inp = sc.next(); int ans = 0; int prev = 0; for(int i=0;i<inp.length();i++){ if(inp.charAt(i) == 'R'){ ans = Math.max...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): a,b=0,0 s=input() for i in s: if i=="L": a+=1 else: if a==0 or a==b: a=0 continue else: b=max(b,a) a=0 print(max(a,b)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for i in range(t): a=0 b=[] s=input() for j in range(len(s)): if(s[j]=="L"): a+=1 else: b.append(a) a=0 b.append(a) b.sort() print(b[len(b)-1]+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s=input() n=1 m=0 for i in range(len(s)): if s[i]!='R': n+=1 else: n=1 if n>m: m=n print(m)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; public class Check{ public static void main(String [] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ String s=sc.next(); int n=s.length(); int len=0; int maxLen=0; if(s.charAt(0)=='L'){ ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; import java.io.*; public class tr0 { static PrintWriter out; static StringBuilder sb; static long mod = 1000000007; static long inf = (long) 1e15; static ArrayList<Integer>[] ad; static int n, p, k; static boolean[] in; public static void main(String[] args) throws Exception { Scanner sc...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for j in range(int(input())): w=0 z = input() a = [] b = 1 ################## for j in z: if j == 'L': b += 1 else: if b: a.append(b) b = 1 if b: a.append(b) print(max(a))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
from __future__ import division import itertools input = raw_input range = xrange filter = itertools.ifilter map = itertools.imap zip = itertools.izip def read_int(): return int(input()) def read_ints(): return list(map(int, input().split(' '))) def read_str(): return input() def read_strs(): ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
x=int(input()) for a in range(0,x): y=input() l=0 ls=0 for b in range(0,len(y)): if y[b]=='R': #print(l) ls=max(ls,l) l=0 else: l+=1 ls=max(ls,l) print(ls+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def solution(frase): inicio = 0 fim = len(frase) + 1 meio = int((inicio + fim) / 2) candidate = 0 while inicio <= fim and fim: if chega(frase, meio): fim = meio -1 candidate = meio else: inicio = meio + 1 meio = meio = int((inicio + fim) /...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for k in range(t): st = input() n = len(st) prev_ind = n d = 0 for i in range(1, n + 1): #print(d) if st[n - i] == 'R': cur_d = prev_ind - (n - i) prev_ind = n - i if cur_d > d: d = cur_d cur_d = prev_ind - (-1)...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main(void) { long long int t, n, str, p, d, p1; string s; set<int> R, L; cin >> t; while (t--) { cin >> s; n = s.size(); str = 0; for (int i = n - 1; i >= 0; i--) { if (s[i] == 'R') { str = i + 1; break; } } ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s=input();ind=[] for i in range(len(s)): if s[i]=='L':ind.append(i) if len(ind)<=1:print(len(ind)+1) else: t=0;Ans=[] for i in range(1,len(ind)): if ind[i]-ind[i-1]==1:t+=1 else:Ans.append(t);t=0 Ans.append(t);print...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for i in range(t): ch=input() L=[len(j) for j in ch.split('R')] print(max(L)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; public class Div_3_627_C { public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { char[] str=sc.next().toCharArray(); Vector<Integer> v=new Vector<>(); v.add(0); for(int i=0;i<str.length;i++) { i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.Stack; public class exp{ public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } St...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for z in range(t): d=input() start=-1 m=0 for j in range(len(d)): if d[j]=="R": m=max(m,j-start) start=j m=max(m,len(d)-start) print(m)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def program(): s=input() overall_max=1 current_max=1 for x in s: if x=='L': current_max+=1 else: if overall_max<current_max: overall_max=current_max current_max=1 if overall_max<current_max: overall_max=current_max ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
from math import * from sys import * t=int(stdin.readline()) for _ in range(t): a=input() n=len(a) c=0 ans=[] for i in range(n): if a[i]=="R": ans.append(c+1) c=0 else: c+=1 ans.append(c+1) print(max(ans))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): string=input() l=list(string) if not "R" in l: print(len(string)+1) else: lst=[0] for i in range(0,len(string)): if string[i]=="R": lst.append(i+1) lst.append(len(string)+1) ans=0 for i in range(len...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s =input() n = len(s) ans = 0 i=0 while i<n: j=i if s[j]=='L': while j<n and s[j]=='L': j+=1 ans = max(ans,j-i) if i==j: i+=1 else: i=j print(ans+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def r(t=int): return list(map(t, input().split())) def ri(t=int): return t(input()) def cd(it): ret_val = dict() for v in it: ret_val[v] = ret_val.get(v, 0) + 1 return ret_val for _ in range(ri()): a = input() m = 0 s = 0 for ai in a: if ai == 'L': s...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string cad; cin >> cad; int len = cad.length(); int contL = 0, contR = 0; for (int i = 0; i < len; ++i) { if (cad[i] == 'L') contL++; if (cad[i] == 'R') contR++; } if (contL == len) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { // Complete the maximumSum function below. private static final Scanner scanner = new Scanner(System.in); public static ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
from sys import stdin t = int(input()) for _ in range(t): string = stdin.readline().strip() maxdist = 1 prev = -1 for i, char in enumerate(string): if char == 'R': maxdist = max(maxdist, i - prev) prev = i maxdist = max(maxdist, len(string) - prev) print(maxdist...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0); int tt; cin >> tt; while (tt--) { string s; cin >> s; vector<int> dp; dp.push_back(0); for (int i = 0; i < s.length(); i++) { if (s[i] == 'R') { dp.push_back(i + 1); } ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for i in range(t): a = input() b = [0] c = [] for j in range(len(a)): if a[j] == "R": b.append(j+1) b.append(len(a)+1) for k in range(len(b)-1): c.append(b[k+1]-b[k]) print(max(c))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> template <class T> T sqr(T x) { return x * x; } template <class T> T lcm(T a, T b) { return a / __gcd(a, b) * b; } template <class T> T minimize(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> T maximize(T &a, T b) { if (a < b) { a = b;...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
def sol(s): rs = [] for i in range(len(s)): if s[i]=="R": if len(rs)==0 and i!=0: rs.append(0) rs.append(i+1) if not rs: return len(s)+1 rs.append(len(s)+1) answer = 0 for i in range(1,len(rs)): answer = max(answer,rs[i]-rs[i-1]) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t = int(input()) for _ in range(t): s = input() n = len(s) m = -1 ans = 0 for i in range(n): if s[i] == 'R': ans = max(i-m, ans) m = i print(max(ans, n-m))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
test=int(input()) for _ in range(test): s=input() arr=[0] for i,x in enumerate(s): if x=='R': arr.append(i+1) arr.append(len(s)+1) ans=0 for i in range(0,len(arr)-1): ans=max(ans,arr[i+1]-arr[i]) print(ans)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; vector<int> pos; pos.push_back(0); for (int i = 0; i < int(s.size()); ++i) { if (s[i] == 'R') pos.push_back(i + 1); } pos.push_back(s.size() + 1); int ans = 0; fo...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int n, pos, maximo; string s; cin >> n; while (n > 0) { cin >> s; pos = -1; maximo = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (i - pos > maximo) { maximo = i - pos; } pos = i; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.Scanner; public class FrogJumps { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int T = scanner.nextInt(); while(T-- > 0) { String s = scanner.next(); char[] arr = new char[s.length()+1]; arr[0] = 'R';...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; import java.io.*; public class lp1{ static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args){ int t = ni(); for(int o=1;o<=t;o++) { char s[] = n().toCharArray(); int n = s.length; int diff=0; int pre=0; for(int i=0;i<n;i++) { if(s[i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
''' ##======================================================================================================================================## ## _____ _ _ _ _____ _ _ _ _ _____ _____ ____ ___ ____ ___ ## ## | / \ | \ / |...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
n=int(input()) for x in range(n): t=input() l=-1 maxs=0 for xy in range(len(t)): if (t[xy]=='R'): maxs=max(xy-l,maxs) l=xy maxs=max(len(t)-l,maxs) print(maxs)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.util.*; import java.io.*; import java.math.*; /* Hepler Class Methods **only Few Imp Ones** * int[][] getIntMatrix(String s,int r,int c) //Works only for int and long * char getCharacterValue(int i) * int getIntegerValueOfCharacter(char c) * boolean isPerfectSquare(int n) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
t=int(input()) for i in range(t): s=str(input()) l=[] x=0 for j in range(len(s)): if (s[j]=="L"): x+=1 continue if (x!=0): l.append(x) x=0 l.append(x) print(max(l)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0); long long tc; cin >> tc; while (tc--) { string str; cin >> str; long long n = str.size(); long long ans = 0, k = 0; for (long long i = 1; i <= n; i++) { if (str[i - 1] == 'R') { ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): best = 0 curr = 0 for c in input(): if c == "R": curr = 0 else: curr += 1 if curr > best: best = curr print(best+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): ans=0 p=0 s=input() for i in s: if i=="L": p+=1 else: p=0 ans=max(ans,p) print(ans+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for i in range(int(input())): s=input() global_L=0 local_L=0 for i in s: if i=='R': global_L=max(local_L,global_L) local_L=0 else: local_L+=1 if local_L!=0: global_L=max(global_L,local_L) print(global_L+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
# -*- coding: utf-8 -*- """Untitled58.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1dS7YykgLJkn7azGB1vqUrBGKbn7EhSDQ """ from math import ceil for _ in range(int(input())): s=input() n=len(s) l=s.count('L') r=s.count('R') if r==0: ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int main() { int t, count = 0, max = 0; bool flag = 0; string s; cin >> t; while (t--) { count = 0; max = 0; flag = 0; cin >> s; if (s.length() == 1) { if (s[0] == 'L') flag = 1; } if (s.length() > 1 && s[s.length() - 1] == 'L') {...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
for _ in range(int(input())): s=input() ans=0 prev=-1 for i in range(len(s)): if s[i]=='R': ans=max(ans,i-prev) prev=i ans=max(ans,len(s)-prev) if prev==-1: ans=len(s)+1 print(ans)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; int t, pos, ans; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> s; ans = pos = 0; s += "R"; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { ans = max(ans, (i + ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Q6 { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(rea...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; long long ans = 1; vector<long long> v; v.push_back(0); for (long long i = 0; i < s.size(); i++) { if (s[i] == 'R') v.push_back(i + 1); } v.push_back(s.size() + 1); for (long long i = 1; i < v.size(); i++) ans = max(a...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n 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 t...
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int m) { if (y == 0) return 1; long long int p = power(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } long long int nCr(long long int n, long long int r, long long int m) { ...