Potato went on an adventure to a magical maze, which rotates a rectangle part on certain timestamps, and brings any cute little potatos within the area along with the rotation.
Potato is having a hard time walking out the maze, and he's getting a bit dizzy since the maze is going round and round.
So you, as a kind and generous student, wanted to help Potato escape the maze.
The rule of the maze goes:
In every second:
1. (note that a cell of 0 can become stone)[Right, Down, Left, Up], if one is block, pick the next direction. (a cell containing negative number is a stone that you can't step on)Note that:
k rotating events happen on different time.


class Potato:
def __init__(self) -> None:
self.i = 0
self.j = 0
self.score = 0
def play(self, time:int, maze:"Maze") -> None:
# Update maze (if there's any event, do the event first)
maze.update_time(time, self)
# TODO
# utilize functions in maze
# 1. pick up the points where you're standing on (take a look in 'class Maze')
# 2. move Potato by checking if next cell is a stone by the priority of [Right, Down, Left, Up]
def get_location_message(self, time:int) -> str:
# TODO
# return the formated the message by the required format
# >> the message printed each second
return f"Where's Potato!!"
def get_summary_message(self, time:int) -> str:
# TODO
# return the formated the message by the required format
# >> the message printed when Potato arrived at bottom right
return f"How much time and score did Potato spend and get!!"
class MazeRotatingEvent:
def __init__(self, t, i, j, w, d) -> None:
self.t = t
self.i = i
self.j = j
self.w = w
self.d = d
class Maze:
def __init__(self, n, m) -> None:
self.n = n
self.m = m
def read_grid(self) -> None:
self.grid = [list(map(int, input().split())) for i in range(self.n)]
def read_k_events(self, k:int) -> None:
self.events = None # TODO replace this with how you want to store MazeRotatingEvents
for i in range(k):
t, i, j, w, d = map(int, input().split())
rotatingEvent = MazeRotatingEvent(t, i, j, w, d)
# TODO store this new MazeRotatingEvent <rotatingEvent>
def is_cell_the_end(self, i:int, j:int) -> bool:
# TODO
# return True if (i, j) is the bottom-right
# return False if (i, j) is not the bottom-right
return
def is_cell_walkable(self, i:int, j:int) -> bool:
# TODO
# return False if (i, j) is out of map or is a stone (negative number)
# return True if (i, j) is in the map and is not a stone (positive number or 0)
return
def pick_up_treasure_at(self, i:int, j:int) -> int:
# TODO
# return the points on (i, j), and because it's picked up, subtract by 1
return
def update_time(self, time:int, potato:Potato) -> None:
# TODO
# check if there's a rotating event on time <time>
# if there's a rotating event, rotate the area, and also move potato's position
pass
n, m, k = map(int, input().split())
magic_maze = Maze(n, m)
magic_maze.read_grid()
magic_maze.read_k_events(k)
cute_potato = Potato()
time = 0
while(True):
old_i, old_j = cute_potato.i, cute_potato.j
cute_potato.play(time, magic_maze)
print(cute_potato.get_location_message(time))
if(magic_maze.is_cell_the_end(cute_potato.i, cute_potato.j)):
print(cute_potato.get_summary_message(time))
break
time += 1
Potato judges your code by the following limitations:
n = m = 4, k = 0n = m < 16, k = 0n,m < 32, k > 0, events[i].d = 0n,m < 32, k > 0, events[i].d = 1n,m < 64, k > 0
Potato's Whisper 1: It's highly recommanded to use the above code, since it saves you alots of time.
Potato's Whisper 2: The template code is actually runnable, you can run it first then edit it.
Potato's Whisper 3: Potato is one of the loveliest food/person, since hashbrowns and fries are made out of it.
Potato's Whisper 4: I'm soo happy you read the question sooo detailed, but you should start coding NOW.
The first line contains 3 integer n,m,k, representing the maze's size is nxm and there will be k rotating events in the future.
Following by n lines, each contains m integers, forming the maze.
Than the final k lines, each contains 5 integers t,i,j,w,d representing:
t(i,j)wd direction (clockwise when d=0 , counter-clockwise when d=1)Limitations:
k events happen on different time tk events' rotating area will not exceed the mapn*m numbers initially on the map are less than 10When every second ends, print where Potato's at by the following format:
<i>, <j>) when t=<t>Where i,j is where Potato ends at on time t.
And finally when he arrives at the bottom right, print a message by the following format:
<t> seconds and got <score> pointsWhich means that Potato arrived at the bottom right corner on time t, and collected score points along the way.