http://codeforces.me/gym/100020
what a fucking problem! if you use scanf to read all n*n matrix n<=2000, you will defintly TLE.... we must read only n+1 number,and get the state....
and there are sepcial test cases for n==1 &&n==2 I want to break my computer when solving this problem....