9/2/25, 10:26 AM Problem - 2070B - Codeforces
|
stdfloat | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST
Educational Codeforces Round 175
B. Robot Program (Rated for Div. 2)
Finished
time limit per test: 2 seconds
memory limit per test: 512 megabytes Practice
There is a robot on the coordinate line. Initially, the robot is located at the point x (x ≠ 0 ). The robot has a
sequence of commands of length n consisting of characters, where L represents a move to the left by one unit
(from point p to point (p − 1) ) and R represents a move to the right by one unit (from point p to point (p + 1) ).
→ Virtual participation
The robot starts executing this sequence of commands (one command per second, in the order they are Virtual contest is a way to take part in past contest,
presented). However, whenever the robot reaches the point 0 , the counter of executed commands is reset (i. e. it as close as possible to participation on time. It is
supported only ICPC mode for virtual contests. If
starts executing the entire sequence of commands from the very beginning). If the robot has completed all you've seen these problems, a virtual contest is not
commands and is not at 0 , it stops. for you - solve these problems in the archive. If you
just want to solve some problem from a contest, a
virtual contest is not for you - solve this problem in
Your task is to calculate how many times the robot will enter the point 0 during the next k seconds. the archive. Never use someone else's code, read
the tutorials or communicate with other person
during a virtual contest.
Input
The first line contains a single integer t (1 ≤ t ≤ 10
4
) — the number of test cases. Start virtual contest
5 18
The first line of a test case contains three integers n , x and k (1 ≤ n ≤ 2 ⋅ 10 ; −n ;
≤ x ≤ n n ≤ k ≤ 10 ).
→ Clone Contest to Mashup
The second line of a test case contains a string s consisting of n characters L and/or R.
Additional constraint on the input: the sum of n over all test cases doesn't exceed 2 ⋅ 10 .
5
→ Submit?
Output Language: GNU G++20 13.2 (64 bit, winlibs)
For each test case, print a single integer — the number of times the robot will enter the point 0 during the next k
seconds. Choose
Choose File No file chosen
file:
Example Submit
input Copy
6
3 2 6 → Contest materials
LLR
2 -1 8
RL Announcement
4 -2 5 Video Tutorial (en)
LRRR
5 3 7 Tutorial #2
LRRLL
1 1 1
L
3 -1 4846549234412827 → CF GetRating
RLR
*1100
output Copy
1 Show All Tags
4 Contest Standings
1
0
1
2423274617206414
Note
In the first example, the robot moves as follows: 2 → 1 → 0 → −1 → −2 → −1. The robot has completed all
–
instructions from the sequence and is not at 0 . So it stops after 5 seconds and the point 0 is entered once.
In the second example, the robot moves as follows: −1 → 0 → 1 → 0 → 1 → 0 → 1 → 0 → 1 . The robot
– – – –
worked 8 seconds and the point 0 is entered 4 times.
In the third example, the robot moves as follows: −2 → −3 → −2 → −1 → 0 → −1 . The robot worked 5
–
seconds and the point 0 is entered once.
In the fourth example, the robot moves as follows: 3 → 2 → 3 → 4 → 3 → 2. The robot has completed all
instructions from the sequence and is not at 0 . So it stops after 5 seconds, without reaching the point 0 .
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Sep/02/2025 10:24:59UTC+5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
Supported by
https://codeforces.com/problemset/problem/2070/B 1/2
9/2/25, 10:26 AM Problem - 2070B - Codeforces
https://codeforces.com/problemset/problem/2070/B 2/2