-
-
Save unilecs/db6fdf9b450f53990f52997e1c7ab7d2 to your computer and use it in GitHub Desktop.
Задача: Тетрадь в клеточку - 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static void Task154(int[,] arr) | |
{ | |
int n = arr.GetLength(0); | |
int[,] d = new int[n + 1, n + 1]; | |
int x = 0; int count = 0; | |
for (int i = 1; i <= n; i++) | |
{ | |
for (int j = 1; j <= n; j++) | |
{ | |
if (arr[i - 1, j - 1] == 0) | |
{ | |
var tempMin = Math.Min(d[i, j - 1], d[i - 1, j]); | |
d[i, j] = Math.Min(tempMin, d[i - 1, j - 1]) + 1; | |
if (d[i, j] == x) | |
{ | |
count++; | |
} | |
if (d[i, j] > x) | |
{ | |
x = d[i, j]; | |
count = 1; | |
} | |
} | |
} | |
} | |
Console.WriteLine(string.Format("X = {0}", x)); | |
Console.WriteLine(string.Format("Count = {0}", count)); | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
var arr = new int[,] | |
{ | |
{ 1, 0, 0, 0, 0, 1 }, | |
{ 0, 1, 0, 0, 0, 0 }, | |
{ 1, 0, 0, 0, 0, 0 }, | |
{ 0, 0, 1, 0, 0, 0 }, | |
{ 0, 0, 0, 0, 1, 0 }, | |
{ 0, 0, 1, 0, 0, 0 } | |
}; | |
Task154(arr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment