Advertisement
100yanov

Untitled

Sep 29th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const nm = gets();
  2. numbers = nm.split(" ");
  3. var n = numbers[0];
  4. var m = numbers[1];
  5. const arr = new Array(n);
  6.  
  7. for(let i = 0; i < n; i++) {
  8.     arr[i] = new Array(m);
  9.     for(let j = 0; j < m; j++) {
  10.         arr[i][j] = +gets();
  11.     }
  12. }
  13.  
  14. var count = 1;
  15. var max = 0;
  16. var chislo = arr[1].length - 2;
  17.  
  18. for (let i = 0; i < arr.length; i++) {
  19.     for (let j = 1; j < arr[i].length; j++) {
  20.         if (arr[i][j] === arr[i][j - 1]) {
  21.             count++;
  22.             continue;
  23.         }
  24.     }
  25.     if (count > max) {
  26.         max = count;
  27.     }
  28.     count = 1;
  29. }
  30.  
  31. for (let j = 0; j < arr.length; j++) {
  32.     for (let i = 1; i < arr[j].length; i++) {
  33.         if (arr[i][j] === arr[i - 1][j]) {
  34.             count++;
  35.             continue;
  36.         }
  37.     }
  38.     if (count > max) {
  39.         max = count;
  40.     }
  41.     count = 1;
  42. }
  43.  
  44.  
  45. for (let i = 1; i < arr.length; i++) {
  46.     if (arr[i][i] === arr[i - 1][i - 1]) {
  47.         count++;
  48.         continue;
  49.     }
  50.  
  51.     if (count > max) {
  52.         max = count;
  53.     }
  54. }
  55.  
  56. count = 1;
  57.  
  58.  
  59. for (let i = 1; i < arr.length; i++) {
  60.     var jay = chislo;
  61.     if (arr[i][jay] === arr[i - 1][jay + 1]) {
  62.         count++;
  63.     }
  64.     if (count > max) {
  65.         max = count;
  66.     }
  67.     chislo--;
  68. }
  69.  
  70. print(max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement