2764long time no see

2764   long time no see

题目描述

Little X lives in (1,1),and little Y lives in (N,N).One day they decide to meet each other.However, the road is full of danger. They can only go to adjacent cells and take time that is equal to the value on the cell.Please tell them the minimum time they should take.

输入格式:

There is a T at the beginning of file, show that there is T case follow.
For every test case, the first line contain one integer N.Then come two N * N matrices A and B.(1000 >= N >= 2)
  If little X wants to go to (i,j),he will spend A(i,j) on moving to adjacent cell (i,j).
  If little Y wants to go to (i,j),he will spend B(i,j) on moving to adjacent cell (i,j).

0<=A(i,j)<=10  0<=B(i,j)<=10

输出格式:

For every case,print the minimum time in one line.

输入样例 复制
2
2
0 8
5 1
10 5
9 0
3
0 5 6
6 2 8
2 2 6
3 8 7
2 5 3
4 3 0
 
输出样例 复制
6
8

说明

6
29
通过提交
时空限制10000ms/64mb
题目来源
评测方式在线评测
题目类型
难        度