DCEPC701 - Amazing Maze
Chintu and his father Nikka, on their vacations, went to The Amazing Maze. But unfortunately, Chintu is has been separated from his father. His father Nikka has to find him as soon as possible in the maze or else Chintu will start crying soon.
The Amazing Maze is actually pretty amazing! The maze is built in a rectangular grid fashion. There are walls (#) and walking cells (.) in the grid. One can only walk through walking cells and so cannot jump off the wall. The amazing part is that each wall becomes a walking cell at some point of time (Neglect the transition time). Alternatively one can say that at some time t1 units, the wall will become walking cell and so one can step on to it at t1 time and at any time after t1. One can only move to adjacent walking cells from a walking cell. Adjacent cells mean the immediate up, down, right and left walking cells. It takes 1 unit of time to go from current cell to any adjacent cell. One can also wait on a particular walking cell for an adjacent wall to become a walking cell.
Nikka has the map of the maze with the information of the time at which the walls becomes walking cells. Also he knows at which walking cell he is situated and at which walking cell Chintu is situated. Help Nikka find out the minimum time required to reach to his son Chintu.
First line contains T, the number of test cases.
Each case begins with two integers, M and N, the dimensions of maze.
Next contains M lines each containing N characters. Each character is either a “#” or a “.” as described above. This maze is the snapshot at time t=0.
Next M lines contain N space separated non negative integers. For each “.”, there will be a 0 and for each “#”, there will be a positive integer which represent the time at which that wall (#) will become a walkable cell.
Next line contains x1 and y1 denoting the position of Nikka in the maze.
Next line contains x2 and y2 denoting the position of Chintu in the maze.
Output T lines each containing an integer, the minimum time required for Nikka to reach Chintu.
For all #’s, time “t” will be > 0 and <= 10^4.
0 0 1 0 0
0 1 2
3 4 0
6 7 0
0 02 2 Output: 4
Any chance Free Pascal or C# could be allowed?
100th ac :)
Not really AMAZING...
Not sure why people are getting WA due to a particular test case.Only trick in this question is to determine what will be the length of an edge connecting two particular nodes in the graph.The rest is implementing a standard algorithm.You can attempt SHOP which is based on a similar concept.
Dafuq is wrong with the 5th test case. -_-
not really an amazing maze, just a simple one
wa in fifth test case
i also tle on 5th test case
@All: I guess there is no weird data in any test case, but all those ones failing at 5th test case probably have the same problem. The only remarkable thing here is, in my opinion, that your algorithm should not start with 0 for starting cell at certain cases, but those cases are not present according to the problem description.Last edit: 2013-07-10 14:41:07
Getting TLE on 5th test case
|Added by:||dce coders|
|Cluster:||Cube (Intel G860)|
|Languages:||ASM32-GCC MAWK BC C-CLANG C C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET|