Hard Accuracy: 42.32% Submissions: 23476 Points: 8
Given a square grid of size N, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find a path from top left cell to bottom right cell by which total cost incurred is minimum. You can move in 4 directions : up, down, left an right.
Note : It is assumed that negative cost cycles do not exist in input matrix.
Input: The first line of input will contain number of testcases T. Then T test cases follow. Each test case contains 2 lines. The first line of each test case contains an integer N denoting the size of the grid. Next line of each test contains a single line containing N*N space separated integers depicting the cost of respective cell from (0,0) to (N,N).
For each test case output a single integer depecting the minimum cost to reach the destination.
1 <= T <= 100
1 <= N <= 100
1 <= grid[i][j] <= 104