using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int n; static bool hasNewMarkedCells(int[,] prevDesk,int[,] currDesk){ bool res = false; for(int i=0;i -1){ res = true; break; } } if(res) break; } return res; } static void Main(String[] args) { n = Convert.ToInt32(Console.ReadLine()); int[,] results = new int[n-1,n-1]; for(int i=0;i=0 && prevDesk[k+i,l-j]==-1){ currDesk[k+i,l-j] = prevDesk[k,l]+1; } if(k-i>=0 && l+j=0 && l-j>=0 && prevDesk[k-i,l-j]==-1){ currDesk[k-i,l-j] = prevDesk[k,l]+1; } if(k+j=0 && prevDesk[k+j,l-i]==-1){ currDesk[k+j,l-i] = prevDesk[k,l]+1; } if(k-j>=0 && l+i=0 && l-i>=0 && prevDesk[k-j,l-i]==-1){ currDesk[k-j,l-i] = prevDesk[k,l]+1; } } } } results[i-1,j-1] = currDesk[n-1,n-1]; } Console.Write(results[i-1,j-1].ToString() + " "); cnt++; } Console.WriteLine(); } } }