Answered step by step
Verified Expert Solution
Question
1 Approved Answer
INPUT: 6 10 5 RRRRRRRRRRUUUUU 1 1 UDDDRLLL -3 -5 LDLDLDDDR 1 2 LLLLUU 3 -2 RDULRLLDR -1 6 RUDURUUUUR OUTPUT: YES YES YES NO
INPUT: 6 10 5 RRRRRRRRRRUUUUU 1 1 UDDDRLLL -3 -5 LDLDLDDDR 1 2 LLLLUU 3 -2 RDULRLLDR -1 6 RUDURUUUUR
OUTPUT: YES YES YES NO YES NO
SOLVE THIS PROBLEM IN C++
You were dreaming that you are traveling to a planet named Planetforces on your personal spaceship. Unfortunately, its piloting system was corrupted and now you need to fix it in order to reach Planetforces. Space can be represented as the XY plane. You are starting at point (0,0), and Planetforces is located in point (Pz, Py). The piloting system of your spaceship follows its list of orders which can be represented as a string 8. The system reads s from left to right. Suppose you are at point (x, y) and current order is si if si = U, you move to (2, 4+1); if si =D, you move to (2, y-1); if si =R, you move to (2+1, y); if Si =L, you move to (x - 1, y). Since string s could be corrupted, there is a possibility that you won't reach Planetforces in the end. Fortunately, you can delete some orders from s but you can't change their positions. Can you delete several orders (possibly, zero) from s in such a way, that you'll reach Planetforces after the system processes all orders? Input The first line contains a single integer t (1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started