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...
import java.util.Calendar; import java.util.*; import java.io.*; import java.lang.*; //import java.math; import java.util.Arrays; public class Rathod { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0) { t--; String s=sc.next(); int 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...
n=int(input()) for i in range(0,n): S=0; s=input().rstrip() x=list(s) W=[] for j in range(0,len(x)): if x[j]=='L': S+=1; else: W.append(S) S=0; W.append(S) print(max(W) +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 t = int(sys.stdin.readline()) for _ in range(t): arr = [0] + list(sys.stdin.readline().strip()) + [0] R_index = 0 d = 0 for i in range(len(arr)): if R_index == 0 and arr[i] == "R": d = i R_index = i elif arr[i] == "R": temp = i - R_inde...
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 i in range(n): s = input() cnt = 0 ans = 0 flag1 = 0 for j in range(len(s)): if flag1: if s[j] == 'L': cnt += 1 else: ans = max(ans, cnt + 1) flag1 = 0 cnt = 0 else: ...
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()) #number of test cases: for k in range(0,n): s = input() maxL = 0 #any right is fine prev = '' cur = 0 for x in range(0,len(s)): if s[x] == 'L': cur += 1 else: cur = 0 if cur > maxL: maxL = cur print(maxL+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...
I = lambda : map(int,input().split()) for _ in range(int(input())): n=input();c=0;k=d=0 l=[0] for i in range(len(n)): if n[i]=='R': l.append(i+1) l.append(i+2) #print(l) for i in range(1,len(l)): d=max(d,l[i]-l[i-1]) print(d)
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() l=['R']+list(s) maxx=0 prev=0 for i in range(1,len(l)): if l[i]=='R': d=i-prev prev=i if d>=maxx: maxx=d maxx=len(l) if maxx==0 else maxx for i in range(len(l)-1,-1,-1): if l[i]=='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.*; public class Cf1324C { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t,i,l,max,s; t=sc.nextInt(); sc.nextLine(); while(t>0) { s=0; max=0; String str=sc.nextLine(); l=str.length(); for (i=0;i<l;i++) { if(str.charAt(i)=='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...
def calcJumps(seq): jumps = 1 maxLength = 0 length = 0 for i in range(len(seq)): if seq[i] == 'L': length += 1 else: if length > maxLength: maxLength = length length = 0 if length > maxLength: maxLength = length if maxLe...
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.Arrays; import java.util.Scanner; public class FrogJumps { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-- > 0){ String str = sc.next()+"R"; char[] charArray =...
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; cin >> n; for (int j = 0; j < n; j++) { string s; cin >> s; int r = 0, rmax = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'L') r++; if (rmax < r) rmax = r; if (s[i] == 'R') r = 0; } cout << rmax + 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 math t = int(input()) for z in range(t): n = input() i = count = maxx = 0 while(True): if(i == len(n)): break if(n[i] == 'L'): count+=1 else: if(count > maxx): maxx = count count = 0 i += 1 if(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 solve(level): ll = 0 index = 0 while(index < len(level)): if level[index] == "R": index += 1 else: cll = 0 while(index < len(level) and level[index] != "R"): cll += 1 index += 1 ll = max(ll,cll) return 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...
t = int(input()) for gg in range(t): s = 'R' + input() + 'R' last = 0 maxx = 0 for i in range(1,len(s)): if s[i] == "R": if maxx < i -last: maxx = i-last last = i print(maxx)
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 reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ def gift(): for _ in range(t): string=input() n=len(string) maxdis=0 prevR=0 for i in range(n): if string[i]=='R': currdis=i+1-prevR maxdis=max(maxdis,curr...
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; import java.util.*; public class E { final static int MAXN = 100_005; final static long MOD = (long) 1e9 + 7; public static void main(String[] args) { FastScanner sc = new FastScanner(); int t = sc.nextInt(); 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...
t=int(input()) for i in range(1,t+1): s=input().split('R') print(len(max(s))+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 i, j, T, sz, fast, last; cin >> T; while (T--) { string str; cin >> str; sz = str.size(); bool at_least_once = false; fast = 0; last = sz; vector<int> diff; for (i = sz - 1; i >= 0; i--) { if (str[i] == '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 t= int(input()) for test in range(t): st = input() longest = 1 actual = 1 for i in range(len(st)): if st[i] == 'L': actual += 1 if actual > longest: longest = actual else: actual = 1 print(longest)
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.*; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); InputReader in = new InputReader(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...
from math import sqrt from collections import defaultdict t = int(input()) while t: t = t - 1 # print(t) a = list(input()) ind = defaultdict(list) for i, tmp in enumerate(a): ind[tmp].append(i + 1) if 'R' not in ind: print(len(a) + 1) continue if 'L' not in ind:...
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 i in range(n): s = input() s = ' ' + s lens = len(s) loc = [0] if 'R' in s: loc = [0] + [j for j, k in enumerate(s) if k == 'R'] loc.append(lens) # print(loc) loc_diff = [0] * len(loc) for j in range(len(loc)-1): loc_diff[j] = loc[j+1] - loc[j]...
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().strip() m = 0 count = 0 for x in s: if x=="L": count+=1 else: if count > m: m = count count = 0 if count > m: m = count print(m+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 I():return list(map(int,input().split())) for __ in range(int(input())): # n=int(input()) s=input() s+="R" d=1 i=len(s)-1 while(i>=0): final=i i-=1 while(i>=0 and s[i]!="R"):i-=1 d=max(d,final-i) print(d)
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 def solve(string): n = len(string) rPositions = [0] for i, ch in enumerate(string, 1): if ch == 'R': rPositions.append(i) rPositions.append(n+1) d = 0 for i in range(len(rPositions)-1): d = max(d, rPositions[i+1] - rPositions[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...
#include <bits/stdc++.h> using namespace std; long long n; vector<long long> m; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) { string s; cin >> s; vector<int> bad; bad.resize(s.size() + 1, 0); for (int j = 0; j < s.size(...
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> v; v.push_back(0); for (int i = 0; i < s.length(); ++i) { if (s[i] == 'R') v.push_back(i + 1); } v.push_back(s.length() + 1); int mn = 0; for (int 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...
for _ in range(int(input())): s = input() r = [0] for i in range(len(s)): if s[i] == "R": r.append(i+1) r.append(len(s)+1) ans = 0 for i in range(len(r)-1): if ans < r[i+1] - r[i]: ans = r[i+1] - r[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...
import sys def findMax(x): n = 0 start = 0 while start < len(x): d = findFirstR(x, start) if d > n: n = d start = start + d return n def findFirstR(x, start): for i in range(start, len(x)): if x[i] == 'R': return i - start + 1 return(len(x) - start + 1) lines = sys.stdin.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 as m def f1(): Testcases=int(input()) for i in range(0,Testcases): Columns=int(input()) InAi=[int(j) for j in input().split(" ")] Oddf=False Evenf=False for k in InAi: if(k%2==0): Evenf=True else: Oddf=True if(Oddf==True and Evenf==True): print("NO") break if(Oddf==...
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.*; public class FrogJumps{ public static void main(String args[]){ Scanner s = new Scanner(System.in); int n = s.nextInt(); for ( int i = 0 ; i < n ; i ++){ Stack<Integer> stack = new Stack<Integer>(); stack.push(0); String input = s.next(); int m = input.length()...
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() a=[] s='R'+s shag=0 for i in range(len(s)-1,-1,-1): if s[i]=='R': a.append(shag+1) shag=0 else: shag+=1 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...
casos = int(input()) for i in range(casos): passos = input() cont_R = 1 cont_R_list = [len(passos)+1] for s in passos+'R': if s == 'R': cont_R_list.append(cont_R) cont_R = 1 if s == 'L': cont_R += 1 if len(cont_R_list) > 1: print(max(cont...
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(raw_input()) for i in range(t): s = raw_input() m = -1 tam = len(s) result = 0 for i in range(tam): if s[i]=='L': result+=1 else: m = max(m,result) result = 0 m = max(m,result); if m == -1: m = tam; print(m+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; scanf("%d", &t); string str; getline(cin, str); while (t--) { getline(cin, str); int d = 0; int c = 0; for (int i = 1; i <= str.size(); i++) { if (str[i - 1] == 'R') { d = max(d, i - c); c = 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...
#onle needs r ? n = int(input()) for _ in range(n): s = list(input()) s2 = [-1]+[i for i in range(len(s)) if s[i]=="R"]+[len(s)] ans = 0 for i in range(len(s2)-1): ans = max(ans,s2[i+1]-s2[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 t, n; string s; int main() { cin >> t; while (t--) { cin >> s; n = s.size(); int resp = 0, cont = 0; for (int i = n - 1; i >= 0; i--) { cont++; if (s[i] == 'R') { resp = max(resp, cont); cont = 0; } } resp = ...
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 = list(input()) pos = [0] pos.extend([(x+1) for x in range(len(s)) if s[x] == 'R']) pos.append(len(s) + 1) ans = 0 for x in range(len(pos) - 1): ans = max(ans, pos[x+1] - pos[x]) 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...
t = int(input()) for i in range(t): s = 'R'+input()+'R' d = 0 gap = 0 for c in s: if c == 'R': gap =0 else: gap += 1 d = max(gap,d) 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...
for _ in [0]*int(input()):print(1 + max(map(len, input().split('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...
from collections import Counter, defaultdict, deque import bisect from sys import stdin, stdout from itertools import repeat import math # sys.stdin = open('input') def inp(): return map(int, raw_input().split()) def inst(): return raw_input().strip() def main(): q = inp()[0] for _ in range(...
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 inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) tests = inp() testcount = 0 while testcount < tests: seq = insr() 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...
from sys import stdin T = int(input()) for _ in range(T): s = stdin.readline().split() s ,= s N = len(s) curr = 0 rights = [] for char in range(N): if s[char] == 'R': rights.append(char) if rights == []: print (N + 1) continue dists = [] dists.append(rights[0] + 1) for i in range(len(rights...
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, gettrace if not gettrace(): def input(): return next(stdin)[:-1] # def input(): # return stdin.buffer.readline() def main(): def solve(): ss = input() res = 1 jump = 1 for s in ss: if s == 'L': jump += 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...
nn=int(input()) for i in range(nn): l=input() l+='R' n=len(l)-1 j=-1 cou=1 for i in range(n+1): if(l[i]=='L'): cou+=1 else: j=max(j,cou) cou=1 j=max(j,cou) print(j)
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...
num = int(input()) for _ in range(num): s = input() + "R" d = 0 cnt = 1 for x in s: if x == "L": cnt += 1 else: d = max([d, cnt]) cnt = 1 if d == 0: c = len(s) - 1 print(d)
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...
numTests = int(input()) for _ in range(numTests): cols = input() longest = 0 count = 0 for ii in range(len(cols)): if cols[ii] == 'L': count += 1 if count > longest: longest = count else: count = 0 print(longest+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() print (max(map(len,s.split('R')))+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; while (t--) { string s; cin >> s; int ans = -1; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { ans = i + 1; break; } } if (ans == -1) { cout << s.size() + 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...
t=int(input()) for i in range(t): s=input() n=len(s) ind=[-1] d=[] co=s.count('R') if co is 0: print(n+1) else: loc=0 for j in range(n): if(s[j]=='R'): ind.append(j) ind.append(n) for j in range(len(ind)-1): 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...
for _ in range(int(input())): s = list(input().strip()) m = 0 temp = -1 for i in range(len(s)): if s[i] == 'R': m = max(m, i - temp) temp = i m = max(m, len(s) - temp) 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...
# cook your dish here t = int(input()) out = [] for i in range(t): maxL = 1 currentL = 1 seq = input() for j in range(len(seq)): c = seq[j] if c == 'L': currentL += 1 else: if currentL > maxL: maxL = currentL currentL = 1 o...
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 import math import bisect def solve(s): n = len(s) max_val = 0 last = 0 for i in range(1, n + 2): if i == n + 1 or s[i-1] == 'R': val = i - last last = i max_val = max(max_val, val) return max_val def main(): for _ in range(int(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...
t = input() left = 'L' right = 'R' def getResult(string): minimum = -1 last = -1 count = 0 for i in range(len(string) - 1, -1, -1): if (minimum < 0 and string[i] == right): minimum = len(string) - i last = i if (minimum > 0): if (string[i] == right...
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) maxi = 0 prev = -1 for i in range(n): if s[i] == 'R': if maxi < i-prev: maxi = i-prev prev = i if prev != n-1: if maxi < n-prev: maxi = n-prev print(maxi)
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): string1=input() temp=[0]*(len(string1)+2) dist=0 max1=0 for i in range(0,len(string1)): dist+=1 if string1[i]=='R': max1=max(dist,max1) dist=0 max1=max(dist+1,max1) print(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...
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
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 = list(input()) l=len(s) c=ans=0 c=1 for i in range(l): if s[i]=='R': ans=max(ans,c) c=1 else: c+=1 ans = max(ans,c) 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...
T = int(input()) for t in range(T): A = input() n = len(A) B = [0] for i in range(n): if A[i] == 'R': B.append(i+1) B.append(n+1) ans = 0 for i in range(len(B)-1): ans = max(ans, B[i+1] - B[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...
for i in range(int(input())): s=input() s="#"+s+"#" n=len(s) mx=-87654333334 r=n-1 step=0 for i in range(n-2,-1,-1): # print('mx,r,s[i],i,step',mx,r,s[i],i,step) if s[i]=='R' or s[i]=="#": if step<=0: mx=r-i step=mx else...
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...
tests = int(input()) for _ in range(tests): jumps = input() n = len(jumps) indices = [0] dists = [] for i in range(n): if jumps[i] == "R": indices.append(i+1) dists.append(i - indices[-2] + 1) #Add the last jump dists.append(n-indices[-1]+1) print(max(dist...
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())): print(len(max(input().split("R")))+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...
/*input 6 LRLRRLL L LLR RRRR LLLLLL R */ import java.math.*; import java.io.*; import java.util.*; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead...
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 [0]*int(input()): s = input() x = 1 arr = [] for i in s: if i == 'L': x += 1 else: if x: arr.append(x) x = 1 if x: arr.append(x) print(max(arr))
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=list(input()) arr=[];brr=[] for i in range(len(s)): if s[i]=='R': arr.append(i+1) arr.insert(0,0) arr.insert(len(arr),len(s)+1) for i in range(len(arr)-1): brr.append(arr[i+1]-arr[i]) print(max(brr))
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): st=input() d,i,flag=1,0,0 while(i<len(st)): if(st[i]=='L'): flag=1 j=i+1 p=1 while(j<len(st) and st[j]=='L'): p+=1 j+=1 d = p if p>d else d i+=(j-i-1) 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...
T = int(input()) for z in range(T): A = str(input()) N = len(A) c = 1; tmp = 0; for i in range(N): if A[i] == 'L': tmp = tmp + 1; else: if tmp+1 > c: c = tmp+1; tmp = 0; if tmp+1 > c: c = tmp+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...
# python3 q3.py < test.txt t = int(input()) for i in range(t): s = input() s += 'R' last_r = 0 diff = 0 for j in range(len(s)): if s[j] == 'R': temp = j - last_r + 1 diff = max(diff, temp) last_r = j + 1 print(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...
import sys import math import bisect from sys import stdin, stdout from math import gcd, floor, sqrt, log2, ceil from collections import defaultdict from bisect import bisect_left as bl, bisect_right as br from collections import Counter from collections import deque ip = lambda : int(stdin.readline()) inp = lambda: ...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
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...
var t = parseInt(readline()); for (var i = 0; i < t; i++) { var s = readline(); var ara = []; ara.push(0); for (var j = 0; j < s.length; j++) { if (s[j] == "R") ara.push(j + 1); } ara.push(s.length + 1); var max = ara[1] - ara[0]; for (var j = 0; j < ara.length - 1; j++) { var diff = ara[j + ...
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 C1324{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0;i < t;i++){ String s = sc.next(); int[] a = new int[200010]; int ctr = 1; a[0] = 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...
T=int(input()) for _ in range(T): sl=input() l=list(sl) s=set(l) if(len(s)==1): l1=list(s) if(l1[0]=="L"): print(len(l)+1) else: print("1") else: c=1 i=0 n=len(l) while(i<n): if(l[i]=="L"): cp...
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() flag = "" d = 1 for j in s: if j == 'L' and flag != "R": flag = 'L' elif j == 'R' and flag != "L": flag = 'R' else: flag = "" break if flag == "L": d = len(s) + 1 elif flag == "R": d = 1 else: count = temp =...
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 import math def read_line(): return sys.stdin.readline()[:-1] def read_int(): ret...
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.*; public class Main { static char s[]; static int arr[]; static int N; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); for (int 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...
def main(): q = int(input()) for _ in range(q): s = "R" + input() + "R" last = 0 inc = 0 for x in range(len(s)): if s[x] == "R": inc = max(inc,x-last) last = x print(inc) 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 _ in range(t): s = input() s += "R" l = [-1] max1=0 for i, c in enumerate(s,0): if c=="R": max1 = max(max1,i-l[len(l)-1]) l.append(i) print(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...
import sys input = sys.stdin.readline for _ in range(int(input())): s = input() d,dPos = 0,0 for i in range(len(s)-1): if(s[i]=='R'): if(i+1-dPos>d): d = i+1-dPos dPos = i+1 if(len(s)-dPos>d): d = len(s)-dPos print(d)
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=[] a=-1 for j in range(len(s)): if(s[j]=="R"): l.append(j-a) a=j l.append(len(s)-a) print(max(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...
from collections import Counter, defaultdict, deque from heapq import heapify, heappush, heappop, heappushpop from sys import stdin # int input int_inp = lambda : int(stdin.readline().strip()) # int array input lst_inp = lambda : [int(i) for i in stdin.readline().strip().split(" ")] # string input str_inp = lambda : 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...
t = int(input()) for i in range(t): string = input() a=[] a.append(0) for i in range(len(string)): if(string[i]=="R"): a.append(i+1) a.append(len(string)+1) max=0 for i in range(len(a)-1): if(a[i+1]-a[i]>max): max=a[i+1]-a[i] print(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...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long tests; cin >> tests; while (tests--) { string s; cin >> s; long long v = 0; long long ma = 0; for (long long i = 0; i < s.length(); i++) { if (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...
//Codeforces 1324C import java.util.Scanner; public class CF1324C { static final Scanner SC = new Scanner(System.in); public static void main(String[] args) { int tests = SC.nextInt(); for (int t = 0; t < tests; ++t) { String jumpConstraints = SC.next(); int minJumpStre...
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 gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } long long int power(long long int x, long long int n) { long long int result = 1; while (n > 0) { if (n % 2 == 1) result = (result * x) % 1000000007; x = (x * x) % 10000...
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 i in range(n): L=[0] ans=0 l=list(map(str,input())) F=['R'] for p in l: F.append(p) F.append('R') for j in range(len(F)): if(F[j]=="R"): L.append(j) for k in range(1,len(L)): ans=max(ans,L[k]-L[k-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 q[200010]; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int t; cin >> t; while (t--) { string s; cin >> s; int l = s.length(); if (l == 1) { if (s[0] == 'L') { cout << 2 << endl; } else { cout << 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 fastio(): from io import StringIO from atexit import register global input sys.stdin = StringIO(sys.stdin.read()) input = lambda : sys.stdin.readline().rstrip('\r\n') sys.stdout = StringIO() register(lambda : sys.__stdout__.write(sys.stdout.getvalue(...
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 answer(jumpArr) : jumpArr = 'R' + jumpArr + 'R' Ls = [] Rindex = -1 for i in range(0, len(jumpArr)) : if jumpArr[i] == 'R' : Ls.append(i-Rindex) Rindex = i if len(Ls) == 0 : Ls.append(1) return max(Ls) testCount = int(input()) testCases = [] for _ 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...
#include <bits/stdc++.h> using namespace std; void solve() { int k = 1, ans = 1, i; string s; cin >> s; for (i = 0; s[i]; i++) { if (s[i] == 'L') k++, ans = max(ans, k); else k = 1; } cout << ans << '\n'; } int main() { std::ios::sync_with_stdio(false); int t; cin >> t; while (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...
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class FrogJumps implements Closeable { private InputReader in = new InputReader(System.in); priva...
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.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf182 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
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=0 mx=0 for j in s: if j=='L': c=c+1 else: mx=max(c,mx) 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...
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class a{ static int[] count; // static int[] count1; static long[] arr; static char[] c; static long[] darr; static long x; 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...
# for _ in range(int(input())): # s,d=map(int,input().split()) # if s>d: # s,d=d,s # x=min(s,d//2) # if s%3==1: # if s==d: # y=(s//3)*2 # else: # y=(s//3)*2+1 # elif s%3==2: # y=(s//3)*2+1 # else: # y=(s//3)*2 # 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 sys t = int(input()) for _ in range(t): a = 'R' a += input() + "R" l = 0 r = 1 ans = 0 while r < len(a): if a[r] == "R": ans = max(ans,r-l) l = r r+=1 else: r+=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...
cases = int(input()) while cases > 0: aux = input() s = 'R' s += aux s += 'R' before = 0 b = False maxi = -1 for i in range(1,len(s),1): if s[i] == 'R': if(maxi < i - before): maxi = i - before before = i print(maxi) 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...
def sol(): T = int(input()) for i in range(T): bridge = input() bridge += "R" prev_r = -1 max_interval = 0 for i in range(len(bridge)): if bridge[i] == "R": interval = i - prev_r prev_r = i max_interval = max(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())): l = list(input()) ans = [] n = len(l) ans.append(0) for i in range(n): if(l[i] == 'R'): ans.append(i + 1) ans.append(n + 1) if(len(ans) == 2): print(n + 1) continue res = 0 for i in range(len(ans)-1): res = 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())): s = input() + ' ' m = 0 t = 0 for i in s: if i == "L": t += 1 else: if t > m: m = t t = 0 print(m+1)