hihoCoder Challenge 27 register

Ended

Participants:323

Verdict:Accepted
Submitted:2017-02-19 19:06:18

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*************************************************************************
       Author:            palayutm
       Created Time :     Sun 19 Feb 2017 06:57:23 PM CST
       File Name:         a.cc
       Description:       
 ************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int a[1005][1005], b[1005][1005], c[1005][1005], d[1005][1005];
int main(int argc, const char *argv[])
{
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j ++) {
      cin >> a[i][j];
      c[i][j] = (a[i][j] == a[i-1][j]+1 ? c[i-1][j] + 1 : 1);
      d[i][j] = (a[i][j] == a[i][j-1]+1 ? d[i][j-1] + 1 : 1);
      b[i][j] = 1;
      if (a[i-1][j-1] == a[i][j]-2) {
        b[i][j] = min(b[i-1][j-1]+1, min(c[i][j], d[i][j]));
      }
      ans = max(ans, b[i][j]);
    }
  }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX