Language: C++

#include <bits/stdc++.h>

using namespace std;

int h, w, nedge, medge = 1;
int field[1400][1400];
int memo[1400][1400];

int solve(int x, int y){

    if(memo[y][x] != 0) return memo[y][x];

    if(!x || !y){
        nedge = 1;
    } else {
        nedge = min(min(solve(x - 1, y - 1), solve(x, y - 1)), solve(x - 1, y)) + 1;
        medge = max(medge, nedge);
    }

    if(field[y][x] == 1) nedge = 0;

    return memo[y][x] = nedge;

}

int main(){

    cin >> h >> w;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> field[i][j];

    memset(memo, 0, sizeof(memo));

    solve(w - 1, h - 1);

    /*
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j)
            cout << memo[i][j];
        cout << endl;
    }
    */

    cout << medge * medge << endl;

}
#include <bits/stdc++.h>

using namespace std;

int h, w, nedge, medge = 1;
int field[1400][1400];
int memo[1400][1400];

int solve(int x, int y){

    if(memo[y][x] != 0) return memo[y][x];

    if(!x || !y){
        nedge = 1;
    } else {
        nedge = min(min(solve(x - 1, y - 1), solve(x, y - 1)), solve(x - 1, y)) + 1;
        medge = max(medge, nedge);
    }

    if(field[y][x] == 1) nedge = 0;

    return memo[y][x] = nedge;

}

int main(){

    cin >> h >> w;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> field[i][j];

    memset(memo, 0, sizeof(memo));

    solve(w - 1, h - 1);

    /*
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j)
            cout << memo[i][j];
        cout << endl;
    }
    */

    cout << medge * medge << endl;

}

Compiler output:
a.cc:53:5: error: redefinition of 'int h'
   53 | int h, w, nedge, medge = 1;
      |     ^
a.cc:5:5: note: 'int h' previously declared here
    5 | int h, w, nedge, medge = 1;
      |     ^
a.cc:53:8: error: redefinition of 'int w'
   53 | int h, w, nedge, medge = 1;
      |        ^
a.cc:5:8: note: 'int w' previously declared here
    5 | int h, w, nedge, medge = 1;
      |        ^
a.cc:53:11: error: redefinition of 'int nedge'
   53 | int h, w, nedge, medge = 1;
      |           ^~~~~
a.cc:5:11: note: 'int nedge' previously declared here
    5 | int h, w, nedge, medge = 1;
      |           ^~~~~
a.cc:53:18: error: redefinition of 'int medge'
   53 | int h, w, nedge, medge = 1;
      |                  ^~~~~
a.cc:5:18: note: 'int medge' previously defined here
    5 | int h, w, nedge, medge = 1;
      |                  ^~~~~
a.cc:54:5: error: redefinition of 'int field [1400][1400]'
   54 | int field[1400][1400];
      |     ^~~~~
a.cc:6:5: note: 'int field [1400][1400]' previously declared here
    6 | int field[1400][1400];
      |     ^~~~~
a.cc:55:5: error: redefinition of 'int memo [1400][1400]'
   55 | int memo[1400][1400];
      |     ^~~~
a.cc:7:5: note: 'int memo [1400][1400]' previously declared here
    7 | int memo[1400][1400];
      |     ^~~~
a.cc:57:5: error: redefinition of 'int solve(int, int)'
   57 | int solve(int x, int y){
      |     ^~~~~
a.cc:9:5: note: 'int solve(int, int)' previously defined here
    9 | int solve(int x, int y){
      |     ^~~~~
a.cc:74:5: error: redefinition of 'int main()'
   74 | int main(){
      |     ^~~~
a.cc:26:5: note: 'int main()' previously defined here
   26 | int main(){
      |     ^~~~