DCP-173: Robotic Problem Back to All Problems

Medium Beginners Problems > Ad-hoc

IITROBO is the robot servant that cleans IIT using his own AI. The AI allows him to move forward one unit and rotate left or right 90 degrees. IIT wants to modify the AI that is given to IITROBO in such way that after cleaning, he will return there from where he started cleaning. As moving IITROBO costs a lot, returning to the starting place should need minimum number of commands to be executed by IITROBO. You will be given the commands following which IITROBO completed his cleaning. Your task is to determine minimum number of commands needed to send IITROBO back to his starting place. The only commands here are— F — this command moves IITROBO one-unit forward L — this command rotates him 90-degree left R — this command rotates him 90-degree right Given the starting position and sequence of commands IITROBO executed to perform his cleaning process, find the minimum number of commands needed to send him back to his starting position. Remember, IITROBO always starts cleaning facing to the East Input: ------ Input starts with an integer T (T ≤ 100) denoting the number of test cases. Each case starts with two integers x, y (0 ≤ x, y ≤ 1 000 000) denoting the starting location of IITROBO. The following line contains a sequence of commands with characters ‘L’, ‘R’, ‘F’. Length of the sequence won’t exceed 1000. Output: ------- For each case, print the minimum number of commands needed to send IITROBO back. Sample Input ------------ 2 0 0 FFRFFLFF 1 5 RFFFFLFFFFLFF Sample Output ------------- 8 7

Problem Setter:

Ariful Hoque Maruf

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 3.00
Go 3.00
Java 3.00
JavaScript 3.00
Objective-C 3.00
Perl 3.00
PHP 3.00
Python 3.00
Python3 3.00
Ruby 3.00
VB.Net 3.00

Problem Stats




# User Language Timing
01 feodorv C 0.00s
02 Robbinb1993 Cpp 0.00s
03 tariqiitju Cpp 0.00s
04 MAHRahat Cpp14 0.01s
05 Morass Cpp14 0.01s
06 Zeronfinity Cpp14 0.32s
07 abinash Cpp14 0.33s
08 sahedsohel Cpp14 0.34s
09 SleepyBrain Cpp14 0.38s
10 habib_rahman Cpp14 0.38s
11 imAnik Cpp14 0.38s
12 rajdipsaha Cpp14 0.39s
13 nasif2587 Cpp14 0.39s
14 murad_al_wajed Cpp14 0.40s
15 Islam_Rafat Cpp14 0.40s
16 sayedgkm Cpp14 0.40s
17 ssavi Cpp14 0.43s
18 priojeet_priyom Cpp14 0.48s
19 Dariwala Cpp14 0.48s
20 skmonir Cpp14 0.48s
21 PKP_007 Cpp14 0.48s
22 xpo6 Cpp14 0.49s
23 fsshakkhor Cpp14 0.49s
24 moshiur_cse15 Cpp14 0.49s
25 mhiceiu Cpp14 0.49s
26 kamrulashraf Cpp14 0.49s
27 farhanhasin Cpp14 0.49s
28 smjlord068 Cpp14 0.49s
29 Double_O Cpp14 0.49s
30 akazad_cse13_ruet Cpp14 0.49s
31 MRITuhin Cpp14 0.50s
32 zyyxxx Cpp14 0.50s
33 MI47 Cpp14 0.51s
34 I_See_You Cpp14 0.51s
35 Fahim_Ahmed Cpp14 0.55s
36 shaft Cpp14 0.57s

Your feedback is our precious!

Or call +88 02 9853138 for support