prompt
string
response
string
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for i in range(t): s = "R" + input() + "R" max_r = 0 now_r = 1 for el in s: if el == "R": max_r = max(max_r, now_r) now_r = 1 else: now_r += 1 print(max_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 s; cin >> s; int f = 1; int n = s.length(); int fr; for (int i = 0; i < n; i++) { if (s[i] == 'R') { fr = i; f = 0; break; } } if (f) cout << n...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(input()): hops = [] move = raw_input(); size = len(move) first,second = move.find('R'),move.rfind('R') if first + second < 0: print size+1 else: if first == second : print max(first+1,size - second) else: hops.append((first+1,first)) for x,y 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; int main() { int t; cin >> t; while (t--) { string s; cin >> s; vector<int> pos; pos.push_back(0); for (int i = 0; i < int(s.size()); ++i) { if (s[i] == 'R') pos.push_back(i + 1); } pos.push_back(s.size() + 1); int a = 0; 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...
MOD = 1000000007 ii = lambda : int(input()) si = lambda : input() dgl = lambda : list(map(int, input())) f = lambda : map(int, input().split()) il = lambda : list(map(int, input().split())) ls = lambda : list(input()) from collections import * for _ in range(ii()): s=si() l=[] x=[] c=0 p=list(...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): string=input() lis=string.split("R") maxi=0 for i in lis: if maxi<len(i): maxi=len(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...
testcases = int(input()) for i in range(testcases): directions = list(input()) arr = [-1] if "R" not in directions: print(len(directions)+1) else: for i in range(len(directions)): if directions[i]=='R': arr.append(i) arr.append(len(directions)) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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() cnt = 0 ans = 0 for i in range(len(s)): if s[i] == 'L': cnt += 1 else: if cnt > ans: ans = cnt cnt = 0 if cnt > ans: ans = cnt 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 sys import * for _ in range(int(stdin.readline())): s=stdin.readline() l=[] k=-1 for i in range(len(s)): if(s[i]=="R"): l.append((i-k)) k=i l.append(len(s)-k-1) 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...
#C. Frog Jumps t = int(input()) for _ in range(t): d = 0 prev = 0 str = '0' + input() + '0' for i in range(len(str)): if(str[i] == 'R' or i == len(str)-1): if i - prev > d: d = i - prev prev = 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...
t=input() from sys import stdin,stdout for i in range(t): s=stdin.readline() l=[1] a=-1 if s.count('R')==0: print len(s) else: for j in range(len(s)-1): if s[j]=='R': l.append(j-a) a=j l.append(len(s)-a-1) 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...
#!/usr/bin/env python3 t = int(input()) for _ in range(t): s = input() max_n = 1 n = 1 for i in range(len(s)): if s[i] == 'L': n += 1 else: n = 1 if n > max_n: max_n = n print(max_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...
from sys import stdin from collections import deque from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin def ii(): return int(stdin.readline()) def fi(): return float(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def fmi(): return map(float, stdin.readline().split()) def...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 Problem1324c { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { String s = sc.next(); int n = s.length(); int m = 0, res = 0; for(int i = 0; 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 os import sys from io import BytesIO, IOBase def solution(s): n = len(s) r_indices = [i + 1 for i in range(n) if s[i] == 'R'] r_indices.append(n + 1) r_indices.insert(0, 0) print(max(r_indices[i + 1] - r_indices[i] for i in range(len(r_indices) - 1))) def main(): 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...
/* ID: davidzh8 PROG: subset LANG: JAVA */ import java.io.*; import java.util.*; import java.lang.*; public class probc { //Start Stub static long startTime = System.nanoTime(); //Globals Go Here //Globals End public static void main(String[] args) throws IOException { FastScanner sc = n...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): s = '#' + input().rstrip() n = len(s) if s.count('R') == 0: print(n) continue last, now = 0, 0 rast = -1 for i in range(1, n): if s[i] == 'R': last = now now = i rast = max(rast, now - last) if 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...
from sys import stdin t = int(stdin.readline()) for _ in xrange(t): s = stdin.readline().strip() ans = 0 a = [] n = len(s) for i in xrange(n): if s[i] == 'R': a.append(i+1) a.append(n+1) pr = 0 for i in a: ans = max(ans,i-pr) pr = 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 java.util.Scanner; public class Main{ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn =new Scanner(System.in); int t =scn.nextInt(); while(t-->0){ String s =scn.next(); System.out.println(res(s)); } } public static int res(String s){ int ans=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...
for _ in range(int(input())): s = input() s = "#" + s + "R" pos = 0 ans = [] for i in range(len(s)): if s[i] == "R": ans.append(i - pos) pos = i print(max(ans))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
# Unmesh Kumar Gupta # CSE'22,IIT Roorkee from math import * mod=1000000007 inf=10000000000000000 def binpow(a,b): global mod if b==1: return a%mod u=binpow(a,b//2) if b%2==0: return (u*u)%mod else: return (u*u*a)%mod def gcd(a,b): if b==0: return 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...
def minD(s): #2e5, sum<2e5; O(n) is enough!? p =-1 m = 0 s = s + 'R' #trick for i in range(len(s)): if s[i]=='R': if i-p>m: m=i-p p = i return m t = int(input()) #1e4 [print(minD(input())) for _ in range(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...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { char ch[200002]; cin >> ch; int n = strlen(ch); int maxi = -1; int pos = 0; int flag = 0; for (int i = 0; i < n; i++) { if (ch[i] == 'R') { flag = 1; if (maxi < (i + 1) - pos...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 q in range(t): s=input() l=0 m=0 for i in s: if i=='L': l+=1 else: m=max(l,m) l=0 m=max(l,m) 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...
for _ in range(int(input())): a=list(input()) md=0 count=0 if a.count('R')==0: print(len(a)+1) elif a.count('L')==0: print('1') else: rr=a[::-1].index('R')+1 lr=a.index('R')+1 for i in range(a.index('R'),len(a)-a[::-1].index('R')): if a[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 Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int cases = scan.nextInt(); scan.nextLine(); for (int k = 0; k < cases ; k++) { String input = scan.nextLine(); int lowerBound = -1; int step = 0; fo...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for _ in range(t): s = input() s = "R" + s + "R" prev = 0 worst = 0 i = 1 while i < len(s): if s[i]=="R": worst = max(worst,i-prev) prev = i i+=1 print(worst)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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) Max = 0 local = 0 for j in range(n): if s[j] == 'L': local += 1 else: Max = max(Max, local) local = 0 Max = max(Max, local) print(Max + 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; vector<long long> r; vector<long long> l; bool check(long long ans, string str) { bool ok = true; long long d; for (long long i = 0; i < r.size(); i++) { if (i == 0) { d = r[i] - 0; if (d > ans) { ok = false; break; } } 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...
for _ in range(int(input())): s=str(input()) count=0 m=0 for i in s: if i=="L": count+=1 else: m=max(count,m) count=0 m=max(count,m) if m==0: print(1) else: 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...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author EigenFunk */ public class Main { public static void main(String[] args) { InputStream...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
""" frog jump """ def d_min(seq): """ will find the min value of d that has to be used """ destination = len(seq) # destination index as start index in -1 possible = [-1] for i, pos in enumerate(seq): if pos == "R": possible.append(i) possible.append(destination) curr = 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...
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t = in.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...
t = int(input()) for tk in range(t): s = list(map(str, input().split('R'))) mx = 0 for i in s: mx = max(mx, len(i)) 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...
#include <bits/stdc++.h> using namespace std; int main() { int t = 0; cin >> t; while (t--) { int dist = 0, ans = 0; int i = 1, last = 0; string s; cin >> s; int n = s.size(); while (i <= s.size()) { if (s[i - 1] == 'R') { ans = max(ans, i - last); last = 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() ans = s.find('R') if ans==-1: print(len(s)+1) else: ans += 1 first = ans-1 temp = ans for i in range(temp, len(s)): if s[i]=='R': ans = max(ans, i-first) first = 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())): arr = list(map(str,input().split('R'))) # print(b) ans = [] for x in arr: ans.append(len(x)) # print(ans) print(max(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...
data = [] n = int(input()) for i in range(n): data.append(input()) def count_max(path): m = 0 c = 0 for i in path: if i == "L": c += 1 else: if c > m: m = c c = 0 return m+1 if c < m else c+1 for i in data: print(count_max(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; set<long long> second[500005]; int main() { long long t; scanf("%lld", &t); while (t--) { string second; cin >> second; long long n = second.size(); vector<long long> v; long long in = -1, dis = n + 1; for (long long i = 0; i < 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...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; vector<long long> r; long long n = s.size(); for (long long i = 0; i < n; i++) { if (s[i] == 'R') { r.push_back(i + 1); } } long long m = r.size(); if (m == 0) { cout << n + 1 << '\n'; return; } lo...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.io.*; import java.util.*; public class GFG { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine().trim()); while (t-- != 0) { //int n = Integer.parseInt(br.readLine().trim()); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 j in range(n): s=input() l=0 c=0 g=0 for i in s: if i=="L": l+=1 if c==len(s)-1: g=max(g,l) else: if l!=0: g=max(g,l) l=0 c+=1 if g==0: print(1) else: pr...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); long long t = 1; cin >> t; while (t--) { string s; cin >> s; long long l, r; long long n = s.length(); l = count(s.begin(), s.end(), 'L'); r = count(s.beg...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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.ArrayList; public class c627 { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer....
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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() if 'R' not in s: print(len(s)+1) continue m=0 i=-1 j=0 while j<len(s): if s[j]=='R': if m<j-i: m=j-i i=j j+=1 if j-i>m: m=j-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 cb_prblm { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int k=0;k<3;k++){ } StringBuilder res = new StringBuilder(); while (t-- > 0) { String stt = scn.next(); int mmax = 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...
import sys input = lambda: sys.stdin.readline().rstrip() def zap(): s = input() n = len(s) a = [] ans = 0 cur = 0 while cur != n: if s[cur] == "L": ans += 1 else: a.append(ans) ans = 0 cur += 1 a.append(ans) return max(a) fo...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): arr = list(input()) count = 0 ans = 0 for k in range(len(arr)): if arr[k] == 'L': count += 1 ans = max(ans, count) else: count = 0 print(ans + 1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): s = input() + 'R' n = len(s) ans,tmp = 0,0 for i in s: if i == 'L': tmp += 1 else: ans = max(ans, tmp) tmp = 0 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...
import sys import math input=sys.stdin.readline t=int(input()) for _ in range(t): #n=int(input()) #l=list(map(int,input().split())) s=input() maxi=0 n=len(s) j=0 for i in range(n): maxi+=1 if s[i]=='R': j=i break diff=0 l_index=j for i in 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...
nCases = int(input()) for _ in range(nCases): jumps = input() bigJump = 1 curJump = 1 for j in jumps: if j == 'L': curJump += 1 if j == 'R': bigJump = max(bigJump, curJump) curJump = 1 print(max(bigJump, curJump)) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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() count = 1 m = 0 for j in s: if j == 'R': if count > m: m = count count = 0 count += 1 if count > m: m = count 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.FileReader; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); for ( int i = 0; i < 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 _ in range(int(input())): s=input() ans=1 c=1 n=len(s) for i in range(n-1,-1,-1): if(s[i]=='R'): if(c>ans): ans=c c=1 else: c=c+1 if(c>ans): 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 i in range(t): s=input() l=list() m=list() l.append(0) for i in range(len(s)): if s[i]=="R": l.append(i+1) l.append(len(s)+1) #print(l) for i in range(1,len(l)): m.append(l[i]-l[i-1]) print(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...
t = int(input()) for _ in range(t): s = input() if s.count('R') == 0: print(len(s) + 1) elif s.count('L') == 0: print(1) else: d = 1 internal = 1 for cell in s: if cell == 'R': internal = 1 else: internal +=...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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() prev=-1 ans=0 for i in range(len(s)): if(s[i]=="R"): ans=max(ans,(i-prev)) prev=i ans=max(ans,(len(s)-prev)) 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 solve(squares): r_idx = [i for i, char in enumerate(squares) if char == "R"] max_dist = -float("inf") for i in range(len(r_idx)-1): diff = r_idx[i+1] - r_idx[i] max_dist = max(max_dist, diff) return max_dist t = int(input()) for _ in range(t): s = input() squares = ["R"]...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): s = list(input().split("R")) s.sort(reverse=True) print(len(s[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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class _25FrogJumps { public static void main(String[] args) { FastInput input = new FastInput(...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 Solution{ // static FastReader in = new FastReader(); static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws Exception{ int t = Integer.parseInt(in.readLine().trim()); 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...
t=int(input()) M=[] def fonction(s): if 'L' not in s: return 1 elif 'R' not in s: return len(s)+1 else: L=s.split("R") return len(max(L))+1 for i in range(t): s=input() M.append(fonction(s)) for k in M: print(k)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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() num = 0 ans = 1 for i in s: num = (num + 1) * (i == "L") ans = max(ans,num + 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...
import java.util.*; public final class C { static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- !=0){ String s = sc.next(); int result = frog(s,s.length()+1); System.out.println(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 heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby import functools import sys import bisect import string import math import time import random def Golf():*a,=map(int,open(0)) def I():return int(input()) def S_():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...
import java.io.*; public class FrogJumps{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testcases = Integer.parseInt(br.readLine().trim()); while(testcases-- != 0){ String direction = br.re...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
# your code goes here t = int(input()) for _ in range(t): str_ = input() r_arr = [] for idx,i in enumerate(str_): if i == 'R': r_arr.append(idx+1) r_arr.append(len(str_)+1) r_arr.insert(0,0) max = 0 for idx,i in enumerate(r_arr[1:]): if max < (i - r_arr[idx]): max = i - r_arr[idx] 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...
testcases = int(input()) for testcase in range(testcases): getstring = str(input()) getlen = len(getstring) dicts = {} getRindex = [] index = 0 for i in getstring: index += 1 if i == "R": getRindex.append(index) if len(getRindex) == 0: print(getlen ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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,floor,tan # import bisect RI = lambda : [int(x) for x in sys.stdin.readline().split()] ri = lambda : sys.stdin.readline().strip() ts = int(ri()) for _ in range(ts): st = ri() arr = [] for i in range(len(st)): if st[i] == 'R': arr.append(i) a...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); long long t = 1; cin >> t; while (t--) { string s; cin >> s; long long l, r; l = r = 0; l = count(s.begin(), s.end(), 'L'); r = count(s.begin(), s.end(), ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t=int(input()) for i in range(t): a=list(input()) k=[0] for i in range(len(a)): if(a[i]=='R'): k.append(i+1) k.append(len(a)+1) # print(k) y=[] for j in range(len(k)-1): y.append(k[j+1]-k[j]) print(max(y))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 case in range(int(input())): string = input() ds = [] d = 1 lastl = None for i, l in enumerate(string): if l == "R": d = 1 ds.append(d) else: if i == (len(string) - 1): if l == "L": d += 1 ds....
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 = list(input()) n = len(s) ss = [0] for i, x in enumerate(s): if x == "R": ss.append(i+1) ss.append(n+1) diff = [ss[i+1] - ss[i] for i in range(len(ss)-1)] print(max(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...
n = int(input()) for _ in range(n): s = input() dList = [0] + [(i+1) for i in range(len(s)) if s[i] == 'R'] dList.append(len(s)+1) ans = 0 for i in range(len(dList) - 1): ans = max(ans, dList[i+1] - dList[i]) print(ans)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int k; cin >> k; while (k != 0) { int res = 0; string instr; cin >> instr; int n = instr.length(); int tcount = 0; for (int i = 0; i < n; ++i) { if (instr[i] == '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...
def solve(): ans = 0 s = 'R' + input() + 'R' arr = [i for i in range(len(s)) if s[i] == 'R'] for i in range(len(arr) - 1): ans = max(ans, arr[i + 1] - arr[i]) return ans t = int(input()) for _ in range(t): print(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...
#include <bits/stdc++.h> using namespace std; int main() { int testcases; cin >> testcases; while (testcases--) { string s; cin >> s; int n = s.length(); int jump = 0; int ans = INT_MIN; for (int i = 0; i < n; i++) { if (s[i] == 'L') jump += 1; else jump = 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...
import sys input = sys.stdin.readline def main(): S = input().strip() ans = 1 cnt = 0 for s in S: if s == "L": cnt += 1 ans = max(ans, cnt + 1) else: cnt = 0 print(ans) for _ in range(int(input())): 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...
for _ in range(int(input())): s = list(input()) l = 1 ans = 1 for i in s: if i == 'L': l += 1 else: ans = max(ans, l) l = 1 ans = max(ans, l) 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 x in range(int(input())): d=[x for x in input()] if('L' not in d): print(1) else: i=0 c=0 #d+=['L'] for x in range(len(d)): if(d[x]=='L'): c+=1 else: if(i<c): i=c c=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; vector<int> vec; int main() { int k; cin >> k; string arr; while (k--) { cin >> arr; int n = arr.length(); int maxLen = 0; for (int i = 0; i < n; i++) { int len = 0; while (arr[i] == 'L') { len++; i++; if (i == n) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): # n = int(input()) # a = list(map(int,input().split())) s = input() prev = -1 ans = 0 fl = False f1 = False for i in range(len(s)): if s[i] == "L": f1 = True if s[i] == "R": fl = True if prev == -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(n): cnt=1 max_cnt=1 pre_s=input() s="R"+pre_s+"R" for i in s: if i=='L': cnt+=1 max_cnt=max(max_cnt,cnt) if i=='R': cnt=1 print(max_cnt)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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 j in range(t): s=input() a=list(s) b=[] ind=-1 for i in range(len(a)): if(a[i]=='R'): b.append(i-ind) ind=i b.append(len(a)-ind) b.sort() print(b[len(b)-1])
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int u = 0; u < t; u++) { string s; cin >> s; int mx = 0; int cnt = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'L') { cnt++; } if (s[i] == 'R' || i == s.size() - 1) { if (...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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())): q=input() e=[] if 'R' in list(q): w=q.split('R') for i in w: e.append(len(i)) print(max(e)+1) else: print(len(q)+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()) while t>0: t-=1 s=input() maxx=0 cnt=0 for i in s: if i=='L': cnt+=1 if cnt>maxx: maxx=cnt else: cnt=0 print(maxx+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 cad; cin >> cad; int l = 0, r = 0; for (int i = 0; i < cad.size(); i++) if (cad[i] == 'R') l = max(l, r), r = 0; else r += 1; l = max(l, r); cout << l + 1 << "\n"; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t=int(input()) for i in range(t): path=input() maxrep=0 rep=0 for i in path: if i=="L": rep+=1 else: if rep>maxrep: maxrep=rep rep=0 if rep>maxrep: maxrep=rep print(maxrep+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 i in range(t): s = list(sys.stdin.readline().rstrip()) m = 0 l = 0 for i in s: if i == 'L': l += 1 m = max(m, l) if i == 'R': l = 0 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...
t = int(input()) for _ in range(t): s = input() count = 0 max_count = 0 for i in range(len(s)): if s[i] == 'L': count += 1 else: count = 0 if count > max_count: max_count = count print(max_count + 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 f = 0, n = s.length(); int ans = -1e9; int il = -1, ir = n; for (int i = 0; i < s.length(); i++) { if (s[i] == 'R') { f = 1; ans = max(ans, abs(il - i)); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.Scanner; public class Main { public static void main(String[] args) throws java.lang.Exception{ // write your code here Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0){ String string=sc.next(); int n=string.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...
t=int(input()) for i in range(t): s=list(input()) check=0 arr=[] arr.append(0) l=len(s) for j in s: if(j=='L'): check=check+1 else: arr.append(check) check=0 arr.append(check) print(max(arr)+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() last_r = -1 s_size = len(s) greater_jump = 0 for c in range(s_size): if s[c] == "R": jump = c - last_r if jump > greater_jump: greater_jump = jump last_r = c if s_size - last_r > greater_jump: greater_jump = s_size - 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...
for i in range(int(input())): x=input() j=len(x) i=j-1 mx=0 while i>=0: if x[i]=='R': mx=max(j-i,mx) j=i i-=1 mx=max(j+1,mx) print(mx)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Dhanin Gupta */ public cla...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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... x=0; x+=1; x=0; #fgfgfg for tini 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...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that 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; string arr; void input() { cin >> arr; } int Answer() { int length = arr.length(); int size = -1; int isFirst = 1; int lastR = -1; for (int i = 0; i < length; i++) { if (arr[i] == 'R' && isFirst == 1) { isFirst = 0; size = i + 1; lastR...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
# Count spaces k = int(input()) for w in range(k): jumps = input() minRight = 1 #right count = 1 for i in jumps: if i == "R": if count > minRight: minRight = count count = 1 else: count += 1 if count > minRig...