Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nm = gets();
- numbers = nm.split(" ");
- var n = numbers[0];
- var m = numbers[1];
- const arr = new Array(n);
- for(let i = 0; i < n; i++) {
- arr[i] = new Array(m);
- for(let j = 0; j < m; j++) {
- arr[i][j] = +gets();
- }
- }
- var count = 1;
- var max = 0;
- var chislo = arr[1].length - 2;
- for (let i = 0; i < arr.length; i++) {
- for (let j = 1; j < arr[i].length; j++) {
- if (arr[i][j] === arr[i][j - 1]) {
- count++;
- continue;
- }
- }
- if (count > max) {
- max = count;
- }
- count = 1;
- }
- for (let j = 0; j < arr.length; j++) {
- for (let i = 1; i < arr[j].length; i++) {
- if (arr[i][j] === arr[i - 1][j]) {
- count++;
- continue;
- }
- }
- if (count > max) {
- max = count;
- }
- count = 1;
- }
- for (let i = 1; i < arr.length; i++) {
- if (arr[i][i] === arr[i - 1][i - 1]) {
- count++;
- continue;
- }
- if (count > max) {
- max = count;
- }
- }
- count = 1;
- for (let i = 1; i < arr.length; i++) {
- var jay = chislo;
- if (arr[i][jay] === arr[i - 1][jay + 1]) {
- count++;
- }
- if (count > max) {
- max = count;
- }
- chislo--;
- }
- print(max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement