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...
def fun(s): n=len(s) prev=-1 last=n d=1 for i in range(len(s)): if s[i]=='R': d=max(d,i-prev) prev=i return max(d,last-prev) t=int(input()) while t: s=input() print(fun(s)) 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...
t=int(input()) for i in range(t): s=input() if(s.count('L')==0): print(1) elif(s.count('R')==0): print(len(s)+1) else: A=[] for i in range(len(s)): if(s[i]=='R'): A.append(i) X=[] for i in range(len(A)-1): X.append(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...
import sys import os import time import collections from collections import Counter, deque import itertools import math import timeit import random from io import BytesIO, IOBase from bisect import bisect_left as bl from bisect import bisect_right as br ######################### # imgur.com/Pkt7iIf.png # #############...
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...
strings = [] output = "" for _ in range(int(input())): strings.append(input) for i in strings: i = input().split('R') l = [len(n) for n in i] output += str(max(l) + 1)+"\n" print(output)
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() b=[0] b+=[i+1 for i in range(len(s)) if s[i]=='R'] b.append(len(s)+1) ans=0 for i in range(1,len(b)): ans=max(ans,b[i]-b[i-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...
def frog(s): c=0 z=[0] for r in s: if r =="L": c+=1 if r=="R": z.append(c) c=0 if c!=0: z.append(c) return max(z)+1 if __name__=="__main__": a=int(input()) for r in range(a): m= input() o=frog(m) print(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...
# Present situation is not the final destination... for tin in range(int(input())): s=str(input()) if "R" not in s: print(len(s)+1) elif "L" not in s: print("1") else: a=[] for _ in range(len(s)): if s[_]=="R": a.append(_) 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...
for _ in range(int(input())): s = 'R' + input() + 'R' m = -1 prev_s = 0 for i, v in enumerate(s): if v == 'R': m = max(i-prev_s, m) prev_s = i 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 JavaApplication98 { /** * @param args the command line argumen * ts */ public static void main(String[] args) { // TODO code application logic here Scanner sc= new Scanner(System.in); int t=sc.nextInt(); while(t--!=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...
from collections import defaultdict,Counter def solve(s): s=['*']+list(s) s.append('R') x=set() prev=0 d=0 for i in range(len(s)): if s[i]=='R': d=max(d,i-prev) prev=i # print(d) return d t=int(input('')) ans=[] while t>0: n=(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...
/* ⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⡎...
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): t-=1 s = input() m = 0 c = 1 p = s[0] for i in s: if(i=="L"): c+=1 else: if(c>m): m = c c = 1 if(c>m): m = c 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.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t; int fshdlfi; t = sc.nextInt(); for (int i = 0; i < t; i++) { int d=1; String a; a=sc.next(); int num=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...
### C. Frog Jumps for _ in range(int(input())): s=input() a=t=0 res='R'+s+'R' for i in range(len(res)): if res[i]=='R': if a<i-t: a=i-t t=i print(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...
for _ in range(int(input())): s=input() ct1=0 ct2=0 flag=False i=0 n=len(s) prev=0 while i<n: if s[i]=='R': ct1=max(ct1,i-prev) prev=i i+=1 ct3=0 ct1=max(ct1,i-prev) pos=len(s)-1 while pos>=0 and s[pos]=='L': ct3+=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 jump(arr): pos = [] pos.append(0) for i, ch in enumerate(arr): if ch == 'R': pos.append(i + 1) pos.append(len(arr) + 1) ans = 0 for i in range(len(pos) - 1): ans = max(ans, pos[i + 1] - pos[i]) return ans n = int(input()) for _ in range(n): s = list(inpu...
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 t = int(input()) for _ in range(t): s = input().strip() a = [0] + [i + 1 for i in range(len(s)) if s[i] == 'R'] + [len(s) + 1] b = [a[i] - a[i - 1] for i in range(1, len(a))] print(max(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 check(S, X): N = len(S) I = -1 while I < N: if N <= X + I: return True P = False for j in range(1, X + 1): if S[I + j] == 'R': I += j P = True break if not P: return False for _ in range(int(input())): S = input() L = 1 R = len(S) + 1 while L < R: M = (L + R) // 2 if check(...
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_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int t, n, i, f = 0; cin >> t; while (t--) { string s; cin >> s; long long int c = 1, maxx = 1; for (auto ch : s) { if (ch == 'L') c++; 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...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; char s[N]; int t; int main() { cin >> t; while (t--) { scanf("%s", s + 1); int len = strlen(s + 1); int maxx = 0, temp = 0; for (int i = 1; i <= len; i++) { if (s[i] == 'L') { temp++; } else { maxx = 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() cou=0 cou1=0 for i in range(len(s)): if s[i] =='R': if cou>cou1: cou1=cou cou=0 elif s[i]=='L': cou+=1 if cou > cou1: cou1 = cou print(cou1+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(0,t): s = input() l = len(s) d = 1 initialpos = -1 for k in range(0,l): if(s[k] == 'R'): if(k - initialpos > d): d = (k) - initialpos initialpos = k if(k == l-1): if(l - initialpos > 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...
def solve(): str = input() ans = [] ans.append(0) for i in range(len(str)): if str[i] == 'R': ans.append(i + 1) ans.append(len(str) + 1) res = 0 for i in range(len(ans)): if i == 0: continue if (ans[i] - ans[i - 1] > res): res = ans[i] - ans[i - 1] return res t = 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 = int(input()) for _ in range(t): s = input().strip() flag = False biggest = 0 count = 0 for i in s: if i == "L": count += 1 else: if count > biggest: biggest = count count = 0 if count > biggest: ...
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; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class c1324 { static class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** call this ...
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_de_testes = int(input()) for i in range(num_de_testes): caso_de_teste = input() aux, valor_min, i = 1, 0, 0 while i < len(caso_de_teste): if caso_de_teste[i] != 'R': aux += 1 else: if aux > valor_min: valor_min = aux aux = 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()) ans = [] for i in range(n): s = 'R'+input()+'R' R = [] last_R = 0 maxx = -1 L = [] for i in range(1, len(s)): if s[i] == 'R': R.append(i) if i-last_R > maxx: maxx = i-last_R last_R = i 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...
from sys import stdin,stdout for _ in range(int(stdin.readline())): string=stdin.readline().strip() lis=string.split("R") maxi=0 for i in lis: if maxi<len(i): maxi=len(i) maxi+=1 stdout.write(str(maxi)) stdout.write("\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...
import re pattern = "L+" t = int(input()) for i in range(t): s = input() f = re.findall(pattern, s) if f: print(len(max(f, key=lambda x: len(x)))+1) else: print(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()) while t: t-=1 s=input() ln=len(s) if(len("".join(set(s)))==1): if(s[0]=='L'): print(ln+1) else: print(1) else: mx=-1 j=-1 for i in range(ln): if(s[i]=='R'): res=i-j j=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...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.length(); vector<int> ind; for (int i = 0; i < n; i++) { if (s[i] == 'R') { ind.push_back(i); } } if (ind.size() == 0) { cout << n + 1 << endl; } else if (ind.size() == 1) { cout << max(n - 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 t in range(int(input())): s = input() n = len(s) cnt = 0 res = 0 for i in range(n): if s[i] == 'L': cnt +=1 else: res = max(cnt , res) cnt = 0 res = max(cnt ,res) print(res + 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class FrogJumps { private static BufferedReader br; public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine());...
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 = sorted(list(set(s.split('R'))), reverse=True) print(len(a[0]) + 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 y in range(t): s = input() ct = 0 ans = 0 for i in s: if(i == 'L'): ct += 1 else: ans = max(ans,ct) ct = 0 print(max(ans,ct)+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 solve(): s = input() mp = 0 p = 0 for i in s: if i == "L": p += 1 else: mp = max(mp, p) p = 0 mp = max(mp, p) print(mp + 1) for i in range(int(input())): solve()
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 _ in range(a): l = input() x = [0] for i in range(len(l)): if(l[i]=='R'): x.append(i+1) x.append(len(l)+1) p = 0 for i in range(0,len(x),1): p = max(p,x[i]-x[i-1]) print(p)
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 test in range(t) : seq = input() if "R" in seq : maxi = max(seq.find("R")+1, len(seq)-seq.rfind("R")) start = 0 for i in range(len(seq)) : if seq[i] == "R" : if i-start >= maxi : maxi = i - sta...
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): t-=1 a=input() cnt1=0 cnt=0 for x in range(len(a)): if a[x]=='L': cnt+=1 else: cnt1=max(cnt,cnt1) cnt=0 cnt1=max(cnt,cnt1) print(cnt1+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 find(val): li = list(val) li.append("R") li = ["R"] +li index = 0 ans = float('-inf') for i in range(len(li)): if li[i] =="R": ans = max(ans,i-index) index = i return ans x = int(input()) for i in range(x): print(find(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...
from math import * import heapq T = int(input()) for _ in range(T): arr = input() j = 0 Arr = [] Arr.append(0) while(arr.find("R",j)!=-1): j = arr.find("R",j)+1 Arr.append(j) Arr.append(len(arr)+1) Max = 0 for i in range(1,len(Arr)): Max = max(Max,Arr[i]-Arr[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 = list(input()) s.insert(0,'R') maxr = -1 pre = len(s) idx = pre-1 while idx!=-1: if s[idx]=='R': maxr = max(maxr,pre-idx) pre = idx idx-=1 print(maxr)
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 int N = 1e9; const long long MN = -1e9; int main() { long long t; cin >> t; while (t--) { string a; cin >> a; long long n = a.length(); long long cnt = 0; long long ans = 0; for (int i = 1; i < n; i++) { if (a[i] == 'L' && a[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...
a=int(input()) letters=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for i in range (a) : string=input() max1=0 c=0 for j in string : if j=="R" : c=0 else : c=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...
for i in range(int(input())): data = "R" + input() + "R" maxDist = 1 last = 0 for i in range(1,len(data)): if (data[i] == "R"): maxDist = max(maxDist,i-last) last = i 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; using ll = long long; using vi = vector<int>; using vii = vector<vi>; using vl = vector<ll>; int main() { int tc; cin >> tc; while (tc--) { int ans = -1; string str; cin >> str; vi pos; pos.push_back(0); for (int i = 0; i < str.size(); 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...
#include <bits/stdc++.h> using namespace std; int num[200005]; int main() { int t; cin >> t; string s; while (t--) { cin >> s; int l = s.length(); num[0] = -1; int x = 1; for (int i = 0; i < l; i++) { if (s[i] == 'R') { num[x] = i; x = x + 1; } } num[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...
test_count = int(input()) for i in range(test_count): line = input() rPoses = [-1] for j in range(len(line)): if line[j] == 'R': rPoses.append(j) rPoses.append(len(line)) diffs = [] last = rPoses[0] for j in range(1, len(rPoses)): diffs.append(rPoses[j] - last) ...
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 ForgJumps { public static void main(String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int k=0; k<t; k++){ String s = in.next(); int n = s.length(); int i = n-1; int d = 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...
# cook your dish here # cook your dish here t = int(input()) for _ in range(t): s = list(input()) a = [] i =0 a.append(0) while i<len(s): if s[i]=='R': a.append(i+1) i = i +1 a.append(i+1) b =[] i= 0 while i<len(a)-1: b.append(a[i+1]-a[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...
#!/usr/bin/env python # coding: utf-8 # In[9]: def frog(s): count=0 maxi=0 countl=0 for i in range(1,len(s)): if s[i]=="L" and s[i-1]==s[i]: count+=1 else: count=0 maxi=max(maxi,count) for i in range(len(s)): if s[i]=="L": countl...
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())): n="R"+input() l=[] for i in range(len(n)): if n[i]=="R": l.append(i) l.append(len(n)) max=0 for i in range(1,len(l)): if l[i]-l[i-1]>max: max=l[i]-l[i-1] 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...
t=int(input()) for _ in range(t): s=input() c=0 cm=0 for x in s: if x=='L': c+=1 else: if c>cm: cm=c c=0 if c>cm: cm=c print(cm+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 def readInt(): return int( rl() ) def readList(): return list(map(int, rl().strip().split())) def readStr(): return rl().strip() def makeMatrix(a, b, value): z = [value]*a for i in range(a): z[i] = [value]*b return z rl = input tc = readInt() while tc: tc -= 1 s = readStr() ...
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...
//package com.company; import java.io.*; import java.util.*; import java.lang.*; public class Main{ public static class FastReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; ...
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): st=input() st='R'+st+'R' v=[0]*(len(st)+1) for i in range(1,len(st)+1): if st[i-1]=='L': v[i]=v[i-1]+1 maxi=-1 for i in v: maxi=max(maxi,i) print(maxi+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...
num = int(input()) max_l = 0 for i in range(num): st = input() l = 0 for i in st: if i == "L": l += 1 if i == "R": if max_l < l: max_l = l l = 0 else: l = 0 if max_l < l: max_l = l l = 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...
def ans(s): s="R"+s+"R" idx=[] for i in range(len(s)): if s[i]=="R": idx.append(i) m=0 for i in range(len(idx)-1): diff=idx[i+1]-idx[i] if diff>m:m=diff print(m) for _ in range(int(input())): ans(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...
import sys from math import ceil,sqrt read=sys.stdin.buffer.readline mi=lambda:map(int,read().split()) li=lambda:list(mi()) cin=lambda:int(read()) def isp(n): i=2 while i*i<=n: if n%i==0: return False i+=1 return True primes=[] for _ in range(cin()): s=input() ct=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, l, m; cin >> t; for (int i = 0; i < t; i++) { string s; int maxi = 0; cin >> s; s.push_back('R'); int counter = 0; for (int k = 0; s[k] != '\0'; k++) { if (s[k] != 'R') counter++; else { maxi = ma...
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): s=input() l=[] l.append(-1) for i in range(len(s)): if(s[i]=='R'): l.append(i) l.append(len(s)) res=1 for i in range(1,len(l)): if(res<l[i]-l[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...
#include <bits/stdc++.h> using namespace std; long long i, j, k, n, m, res, c1, c0; long long a[200009]; string s; set<long long> st; queue<long long> q; int main() { int nt; cin >> nt; while (nt--) { cin >> s; s = 'R' + s; s += 'R'; long long last = 0, res = 0; for (i = 0; i < s.length(); 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 tc in range(int(input())): s='R'+input()+'R' c=s.count('R') m=-100 ar=[] for i in range(len(s)): if s[i]=='R': ar.append(i) for i in range(len(ar)-1): m=max(m,abs(ar[i]-ar[i+1])) 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.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.Stack; public class ROUGH{ public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { 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...
import java.lang.*; import java.util.*; public class Test { 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 max=0; int count=0; for(int 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...
#include <bits/stdc++.h> using namespace std; void solve() { int T; cin >> T; for (int cas = 1; cas <= T; ++cas) { string str; cin >> str; int sz = str.size(); int ans = sz + 1; auto possible = [&](int index) { bool flag = true; for (int i = 0, k; i < sz; i++) { int u = 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 i in range(t): s = input() last = s[0] count = 1 mx = 1 for j in range(1, len(s)): if last == s[j] and last == "L": count += 1 else: count = 1 if count > mx: mx = count last = s[j] if "L" in s: 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...
# cook your dish here from collections import defaultdict t=int(input()) for _ in range(t): d={} d=defaultdict(lambda:0,d) #n=int(input()) s=input() a=0 cur=0 k=1 for i in s: if i=="R": if k-cur>a: a=k-cur cur=k k+=1 if a==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...
def lowestPath(str): rightStep = -1 leftStep = 0 if (len(str) == 1) and (str[0] == 'R'): return 0 for i in range(len(str)): if(str[i] == 'L'): leftStep+=1 else: if(leftStep > rightStep): rightStep = leftStep leftStep = 0 else: if (leftStep > rightStep): retur...
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.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); sc.nextLine(); for(int q=0;q<t;q++) { String str=sc.nextLine(); ...
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 arr[10005], h[10005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t, n, i; string st; cin >> t; while (t--) { cin >> st; int ans = 0, cnt = 0; n = st.length(); for (i = 0; i < n; i++) { if (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 i in range(0,t): st=input() st='R'+st+'R' dist=0 ref=0 for i in range(1,len(st)): if st[i]=='R': if i-ref>=dist: dist=i-ref ref = i print(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 t in range(int(input())): s = input() ans = 0 count = 0 for i in range(len(s)): if(s[i] == 'L'): count+=1 else: count = 0 if(count>ans): ans = count 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...
from __future__ import division, print_function def get_ints(): return map(int, input().strip().split()) def get_array(): return list(map(int, input().strip().split())) def main(): for _ in range(int(input())): s = input() arr = list(s) #print(arr) cnt, res = -1, [0] for 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 sys I=sys.stdin.readline ans="" for _ in range(int(I())): s=I() s=s[0:len(s)-1] #s.strip('\n') if 'R' not in s: ans+="{}\n".format(len(s)+1) elif "L" not in s: ans+="{}\n".format(1) else: r=[] i=0 j=i while i<len(s) and j<len(s): if s[i]=="R": j=i+1 while j<len(s): if s[j]=="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...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string n; cin >> n; int l = n.length(); int rmax; for (int i = l - 1; i >= 0; i--) { if (n[i] == 'R') { rmax = l - i; break; } if (i == 0) rmax = l + 1; } int 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...
t=int(input()) for i in range(t): s='R'+input() d=0 for j in s: if j=='R': c=1 else: c+=1 d=max(d,c) 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...
#include <bits/stdc++.h> using namespace std; template <class _T> inline void read(_T &_a) { bool f = 0; char _c = getchar(); _a = 0; while (_c < '0' || _c > '9') { if (_c == '-') f = 1; _c = getchar(); } while (_c >= '0' && _c <= '9') { _a = (_a << 3) + (_a << 1) - '0' + _c; _c = getchar();...
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.util.stream.Collectors; public class Main { void solve() { String line = in.nextLine(); int max = 0; int start = -1; for(int i = 0;i<line.length();i++){ if(line.charAt(i) == 'R'){ max = Math.max(max, i-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...
import re, math, decimal, bisect def read(): return input().strip() def iread(): return int(input().strip()) def viread(): return [int(_) for _ in input().strip().split()] def round(n): return int(n + 0.5) DEBUG = 1 # DEBUG = 0 def debug(*args, **kwargs): if DEBUG: print(*args, **kwargs) # code goes here 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...
for q in range(int(input())): s = input() + 'R' ind = 0 res = 0 x = 0 while 1: x = s.find('R', x) if x == -1: break else: res = max((x - ind) + 1 ,res) x+=1 ind = x print(res)
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())): a=input() n=len(a) ans=1 k=-1 for i in range(n): if a[i]=='R': ans=max(ans,i-k) k=i if k!=n-1: ans=max(n-k,ans) 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...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(100000) input = sys.stdin.readline INF = 2**62-1 def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().spli...
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.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.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...
import sys # from collections import Counter inp = sys.stdin.readline ans = "" for _ in range(int(inp())): s = inp() # print([i for i in s.strip().split("R")]) # print([len(i) for i in s.split("R")]) ans += str(max(len(i) for i in s.strip().split("R"))+1)+"\n" 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...
def main(): t = int(input()) for _ in range(t): s = input() pos = [0] for i, ch in enumerate(s): if ch == 'R': pos.append(i+1) pos.append(len(s)+1) d = 0 for i in range(len(pos)-1, 0, -1): d = max(d, pos[i]-pos[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 t in range(int(input())): string = input() ultimoR = 0 distR = 0 flagR = False for char in range(len(string)): if(string[char] == "R" and not flagR): flagR = True ultimoR = char distR = char + 1 elif(string[char] == "R"): distR = ma...
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.Collections; import java.util.Scanner; import java.util.Arrays; /** * @author Alice */ public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner str = new Scanner(System.in); int t = str.nextInt(); whi...
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 jump(s): contl = 0 d = 0 for e in range(len(s)): if(s[e] == "L"): contl += 1 else: if(contl > d): d = contl contl = 0 if(contl > d): d = contl return d+1 t = int(input()) for a in range(t): s = input() 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): way = list(input()) old_r = 0 new_r = 0 for elem in way: if elem == 'L': new_r += 1 else: old_r = max(old_r, new_r) new_r = 0 old_r = max(old_r, new_r) print(old_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...
//import java.util.*; import java.io.*; public class CF2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int t = Integer.parseInt(br...
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()): str = input() a = 1 aray = [] for j in str: if j == 'L': a += 1 else: if a: aray.append(a) a = 1 if a: aray.append(a) print(max(aray))
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 mini=[] reset=0 for i in range(len(s)): if s[i]=='L' and reset<=ans: ans+=1 reset+=1 else: reset = 0 mini.append(ans) ans=0 mini.append(ans) print(max(mini)+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 collections import deque import sys sys.setrecursionlimit(5000) if __name__ == '__main__': t = int(input().rstrip()) for _ in range(t): arr = [ch for ch in input().rstrip()] jump = [0] i = 0 while i<len(arr): if arr[i]=='R': jump.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().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...
import java.io.BufferedReader; import java.io.InputStreamReader; public class frogJump { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while (t > 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): s = input() n = len(s) count = [] temp = 1 flag = 0 dp = [0]*n for i in range(n): if i==0: if s[0] == "L": dp[i] = 1 else: if s[i] == "L": dp[i] = dp[i-1] + 1 m = max(dp) prin...
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 = list(s) s1 = list(set(l)) if(len(s1)==1): if(s1[0]=="L"): print(len(l)+1) elif(s1[0]=="R"): print(1) else: l1 = s.split("R") c=1 for j in l1: x = list(j) c = ma...
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 Ishu { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int t,i,temp=0,max=0; String str; t=scan.nextInt(); while(t-->0) { temp=max=0; str=scan.next(); for(i=0;i<str.length();++i) { if(str.charAt(i)=='L') ++temp; 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...
t = int(input()) ans = [] for _ in range(t): s = 'R' + input() + 'R' last_r = 0 max_len = 0 for i in range(len(s)): if (s[i] == 'R'): if (max_len < i - last_r): max_len = i - last_r last_r = i ans.append(max_len) print('\n'.join(str(i) for i...