Robot
TCCC '03 Finals · 2003-04-05 · by lars2520
Problem Statement
A very simple robot moves in a random cardinal or diagonal direction (cardinal directions are north, south, east and west, and diagonal directions are north-east, north-west, south-east, and south-west) each timestep. Thus, the robot has a 12.5% chance of trying to move in each of 8 directions. If the robot moves in a diagonal direction, it moves one unit left or right, and then one unit up or down (both in the same timestep), depending on the direction. If the robot moves in a cardinal direction, it moves 1 unit in that direction. Given a
Constraints
- floor has between 1 and 50 elements, inclusive.
- Each element of floor has between 1 and 50 characters, inclusive.
- Each element of floor has the same number of characters.
- Each character of each element of floor is either a '.', an 'R', or an 'X'.
- There is exactly one 'R' in floor.
- The input will not cause rounding errors. In other words, the actual double probability will not be within .000001 of .xxx000, where the x's represent digits, unless it is exactly 0.
- time will be between 0 and 1000, inclusive.
- x will be between 0 and the length of the first element of floor - 1.
- y will be between 0 and the length floor - 1.
{"R.XX",
"..XX",
"..XX",
"...."}
3
3
7
Returns: 1
{".....", ".X...", ".R..."}
1
2
619
Returns: 71
{"...", "..X", "X..", ".X.", "...", "...", "...", "X..", "X..", "X..", "...", "X.X", "...", ".X.", "...", ".R.", ".XX", "...", "...", "...", ".X.", ".X.", "...", "...", "...", "X..", ".XX", "...", ".X.", "...", "..X", "X..", "...", "...", ".XX", "X..", "...", "..X", "..X", "X.X", "...", "..."}
1
15
937
Returns: 16
{"..X..X....X.", "..X....XX.R."}
10
1
633
Returns: 72
{"...X...R..."}
7
0
602
Returns: 142
Submissions are judged against all 41 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Robot with a public method int getProb(vector<string> floor, int x, int y, int time) · 41 test cases · 2 s / 256 MB per case