All submissions for this problem are available.
Newly launched Robot is given the name LastRunner. Robot is programmed to accept a number of paths that he should take to reach final destination. Robot is initially at point with co-ordinates(0,0) facing in the positive direcction of X-axis. Robot is instructed by the user to reach its final destination by taking specified paths. User can instruct the Robot to rotate in anticlockwise or clockwise direction by a certain angle specified in degrees, followed by distance to be covered in the mentioned direction. The process occurs such that the Robot first rotates in its position and then after achieving the specified directions, moves ahead to cover the distance. The robot is bound to follow the instructions till its last run or the last move provided that it is assured to reach the final destination in its last step else it needs to change only its final move. Robot in his remaining last run (assigned number of paths, if he cannot complete before the last run) chooses the shortest path between last reached point (point till robot obeyed the user's given path) and final destination. Our job is to calculate the total distance covered by robot.
An integer N.
Each next lines will have a character to denote anticlockwise or clockwise followed by 2 floating numbers for degree of angle rotation and distance to be covered in the direction robot is facing.
character(A or C or any other) Degrees Distance
Any character except A or C will terminate accepting paths.
N-integer value, number of paths robot should take to reach final destination.
Distance precised rounded to 2 digits after decimal
- 1 <= N <= 20000
Input: 4 A 90.0 40.0 C 90.0 36.0 C 90.0 4.0 C 0.0 31.5 C 0.0 4.5 C 90.0 36.0 E Output: 130.91
Path instructed by user:
Path 1- A 90.0 40.0 : Reaches (0,40) Total Distance till now : 40
Path 2- C 90.0 36.0 : Reaches (36,40) Total Distance till now : 76
Path 3- C 90.0 4.0 : Reaches (36,36) Total Distance till now : 80
Path 4- C 0.0 31.5 : Reaches (36,4.5) Total Distance till now : 80
Path 5- C 0.0 4.5 : Reaches (36,0) Total Distance till now : 80
Path 6- C 90.0 36.0 : Reaches (0,0) Total Distance till now : 80
Robots do not travel Path 4, 5 and 6 as he is remaining with last run, and he then directly travels from (36,36) to (0,0).
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.