KATHTHI - KATHTHI
Kathiresan is initially locked at cell (0,0) in a highly guarded rectangular prison of order RxC. He must reach the gate at (R-1,C-1) in order to escape from the prison. Kathiresan can move from any cell, to any of it's 4 adjacent cells (North, East, West and South). If Kathiresan is currently at (x1,y1), then he can move to (x2,y2) if and only if abs(x2-x1)+abs(y2-y1) == 1 and 0<=x2<R and 0<=y2<C
Kathiresan somehow manages to get the map of the prison.
If map[x1][y1] == map[x2][y2] then Kathiresan can move from (x1,y1) to (x2,y2) without killing any guards.
If map[x1][y1] != map[x2][y2], then Kathiresan can move from (x1,y1) to (x2,y2) by killing a guard.
Given the map of the prison, find the minimum number of guards Kathiresan must kill in order to escape from the prison.
The first line consists of an integer t, the number of test cases. For each test case, the first line consists of two integers R and C representing the order of the rectangular prison followed by R strings representing the map of the rectangular prison.
For each test case find the minimum number of guards Kathiresan must kill in order to escape from the prison.
1 <= t <= 10
2 <= R <= 1000
2 <= C <= 1000
'a' <= map[i][j] <= 'z'
Try to implement 0-1 [spoiler] over dijkstra to get better time complexity .Last edit: 2021-06-18 17:41:46
Take advantage of 0 and 1 weight
I'm also a flaming faggot.Last edit: 2021-03-08 00:52:42
I'm a flaming faggot.Last edit: 2021-01-12 12:21:22
AC in one goes Yayy!!
Can someone please review my Java submission https://ideone.com/I2hWsg ?
[spoiler] bfs learn it and apply itLast edit: 2020-01-27 10:51:09
This is a great problem. Thanks @cegprakash!
Is it possible to implement it with dynamic programming ?
tried with [stop spoiling other people]Last edit: 2019-09-30 14:45:33