criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    	if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
    auto update = [&](int i, int j, int x) {
        if (dist[i][j] != INF) return;
        dist[i][j] = x;
        q.push(P(i,j));
      };
    update(si,sj,0);
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second; q.pop();
        rep(dir,4) {
          int ni = i+di[dir], nj = j+dj[dir];
          if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
          if (s[ni][nj] == '#') continue;
          update(ni,nj,dist[i][j]+1);
        }
    }
    rep(i,h)rep(i,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:5:11: error: two or more data types in declaration of 'type name'
    5 | using P = pair<int,int>
      |           ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:18:52: error: 'INF' was not declared in this scope
   18 |         vector<vector<int>> dist(h, vector<int>(w, INF));
      |                                                    ^~~
a.cc:19:15: error: 'P' was not declared in this scope
   19 |         queue<P> q;
      |               ^
a.cc:19:16: error: template argument 1 is invalid
   19 |         queue<P> q;
      |                ^
a.cc:19:16: error: template argument 2 is invalid
a.cc: In lambda function:
a.cc:23:11: error: request for member 'push' in 'q', which is of non-class type 'int'
   23 |         q.push(P(i,j));
      |           ^~~~
a.cc: In function 'int main()':
a.cc:26:15: error: request for member 'empty' in 'q', which is of non-class type 'int'
   26 |     while (!q.empty()) {
      |               ^~~~~
a.cc:27:19: error: request for member 'front' in 'q', which is of non-class type 'int'
   27 |         int i = q.front().first;
      |                   ^~~~~
a.cc:28:19: error: request for member 'front' in 'q', which is of non-class type 'int'
   28 |         int j = q.front().second; q.pop();
      |                   ^~~~~
a.cc:28:37: error: request for member 'pop' in 'q', which is of non-class type 'int'
   28 |         int j = q.front().second; q.pop();
      |                                     ^~~
a.cc:37:19: error: 'j' was not declared in this scope
   37 |       if (dist[i][j] == INF) continue;
      |                   ^
a.cc:38:30: error: 'j' was not declared in this scope
   38 |       ans = max(ans, dist[i][j]);
      |                              ^
Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
//左　上　右　下

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int max = 0;

    rep(si, h)rep(sj, w){
        if(s[si][sj]=='#') continue;
        vvi dist(h, vi(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j));    
        };
        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front.fi;
            int j = q.front.se; q.pop();
            rep(dir, 4){
                int ni = i+di[dir];
                int nj = j+dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s[ni][nj]=='#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, h)rep(j, w){
            if(dist[i][j] == INF) continue;
            if(max < dist[i][j]) max = dist[i][j];
        }
    }
    cout << max << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:23: error: invalid use of member function 'std::queue<std::pair<int, int> >::front' (did you forget the '()' ?)
   53 |             int i = q.front.fi;
      |                     ~~^~~~~
a.cc:54:23: error: invalid use of member function 'std::queue<std::pair<int, int> >::front' (did you forget the '()' ?)
   54 |             int j = q.front.se; q.pop();
      |                     ~~^~~~~
Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
//左　上　右　下

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int max = 0;

    rep(si, h)rep(sj, w){
        if(s[si][sj]=='#') continue;
        vvi dist(h, vi(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return 0;
            dist[i][j] = x;
            q.push(P(i, j));    
        };
        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front.fi;
            int j = q.front.se;
            rep(dir, 4){
                int ni = i+di[dir];
                int nj = j+dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s[ni][nj]=='#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, h)rep(j, w){
            if(dist[i][j] == INF) continue;
            if(max < dist[i][j]) max = dist[i][j];
        }
    }
    cout << max << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:23: error: invalid use of member function 'std::queue<std::pair<int, int> >::front' (did you forget the '()' ?)
   53 |             int i = q.front.fi;
      |                     ~~^~~~~
a.cc:54:23: error: invalid use of member function 'std::queue<std::pair<int, int> >::front' (did you forget the '()' ?)
   54 |             int j = q.front.se;
      |                     ~~^~~~~
a.cc: In lambda function:
a.cc:49:19: warning: control reaches end of non-void function [-Wreturn-type]
   49 |             q.push(P(i, j));
      |             ~~~~~~^~~~~~~~~
Language: C++

#include<iostream>
#include<queue>
#include<algorithm>
#define r first
#define c second
using namespace std;
typedef pair<int, int> Point;
const int BUF = 25;


int row, col;
bool isWall[BUF][BUF];

void read() {
    cin >> row >> col;
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            char ch;
            cin >> ch;
            isWall[i][j] = ch == '#';
        }
    }
}


int bfs(int initR, int initC) {
    queue<Point> Q;
    int cost[BUF][BUF] = {};
    
    Q.push(Point(initR, initC));
    memset(cost, -1, sizeof(cost));
    cost[initR][initC] = 0;

    while (!Q.empty()) {
        Point cur = Q.front();
        Q.pop();

        static int dr[] = {-1, 0, 1, 0};
        static int dc[] = {0, 1, 0, -1};

        for (int i = 0; i < 4; ++i) {
            int nr = cur.r + dr[i];
            int nc = cur.c + dc[i];
            if (!(0 <= nr && nr < row && 0 <= nc && nc < col)) continue;
            if (isWall[nr][nc]) continue;
            if (cost[nr][nc] != -1) continue;
            cost[nr][nc] = cost[cur.r][cur.c] + 1;
            Q.push(Point(nr, nc));
        }
    }

    int maxV = 0;
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            maxV = max(maxV, cost[i][j]);
        }
    }
    return maxV;
}


void work() {
    int maxV = 0;
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            if (!isWall[i][j]) {
                maxV = max(maxV, bfs(i, j));
            }
        }
    }
    cout << maxV << endl;
}


int main() {
    read();
    work();
    return 0;
}


Compiler output:
a.cc: In function 'int bfs(int, int)':
a.cc:31:5: error: 'memset' was not declared in this scope
   31 |     memset(cost, -1, sizeof(cost));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | #define r first
Language: C++

#include <bits/stdc++.h>
#define inf 1000000007
using namespace std;

int n,m,maxv=-1;
char a[25][25];
int GA[25][25][25][25];

int main()
{
	cin>>n>>m;
	memset(a,' ',sizeof(a))
	memset(GA,inf,sizeof(GA))
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  cin>>a[i][j];
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (a[i][j]==a[i][j-1]&&a[i][j]=='.')  GA[i][j][i][j-1]=GA[i][j-1][i][j]=1;
			if (a[i][j]==a[i][j+1]&&a[i][j]=='.')  GA[i][j][i][j+1]=GA[i][j+1][i][j]=1;
			if (a[i][j]==a[i+1][j]&&a[i][j]=='.')  GA[i][j][i+1][j]=GA[i+1][j][i][j]=1;
			if (a[i][j]==a[i-1][j]&&a[i][j]=='.')  GA[i][j][i-1][j]=GA[i-1][j][i][j]=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  GA[i][j][i][j]=0;
	}
	for (int ki=1;ki<=n;ki++)
	{
		for (int kj=1;kj<=m;kj++)
		{
			if (a[ki][kj]=='#')  continue;
			for (int ii=1;ii<=n;ii++)
			{
				for (int ij=1;ij<=m;ij++)
				{
					if (a[ii][ij]=='#')  continue;
					for (int ji=1;ji<=n;ji++)
					{
						for (int jj=1;jj<=m;jj++)
						{
							if (a[ji][jj]=='#')  continue;
							if (GA[ii][ij][ji][jj]>GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj])
							{
								GA[ii][ij][ji][jj]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
								GA[ji][jj][ii][ij]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
							}
						}
					}
				}
			}
		}
	}
	for (int ii=1;ii<=n;ii++)
	{
		for (int ij=1;ij<=m;ij++)
		{
			for (int ji=1;ji<=n;ji++)
			{
				for (int jj=1;jj<=m;jj++)
				{
					if (GA[ii][ij][ji][jj]>n*m)  continue;
					else maxv=max(maxv,GA[ii][ij][ji][jj]);
				}
			}
		}
	}
	cout<<maxv<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:32: error: expected ';' before 'memset'
   12 |         memset(a,' ',sizeof(a))
      |                                ^
      |                                ;
   13 |         memset(GA,inf,sizeof(GA))
      |         ~~~~~~                  
a.cc:14:22: error: 'i' was not declared in this scope
   14 |         for (int i=1;i<=n;i++)
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;
int h,w;
const int dx[]={1,0,-1,0};
const int dy[]={0,-1,0,1};
bool judge(int i,int j)
{
  if(i<0||i>=h||j<0||j>=w) return false;
  else return true;
}

int main()
{
  cin>>h>>w;
  vector<string> s(h);
  for(auto&& e: s) 
  {
    cin>>e;
  }
  int ans=0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if(s[i][j]=='#') continue;
      vector<vector<int>> num_field(h,vector<int>(w,-1));
      num_field[i][j]=0;
      queue<pair<int,int>> next_point;
      next_point.push(make_pair(i,j));
      while(!next_point.empty())
      {
        int x=next_point.front().first;
        int y=next_point.front().second;
        next_point.pop();
        for (int k = 0; k < 4; ++k)
        {
          int nx=x+dx[k],ny=y+dy[k];
          if(judge(nx,ny,h,w)&&num_field[nx][ny]==-1&&s[nx][ny]=='.')
          {
            next_point.push(make_pair(nx,ny));
            num_field[nx][ny]=1+num_field[x][y];
          }
        }
      }
      for (int x = 0; x < h; ++x)
      {
        for (int y = 0; y < w; ++y)
        {
          ans=(num_field[x][y]>ans)?num_field[x][y]:ans;
        }
      }
    }
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:19: error: too many arguments to function 'bool judge(int, int)'
   39 |           if(judge(nx,ny,h,w)&&num_field[nx][ny]==-1&&s[nx][ny]=='.')
      |              ~~~~~^~~~~~~~~~~
a.cc:7:6: note: declared here
    7 | bool judge(int i,int j)
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int ans = 0;
    rep(Si, H)rep(Sj, W) {
        if (S[Si][Sj] == '#') continue;
        vector<vector<int>> dist(H, vector<int>(W, INF))
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j));  // .emplace(i, j)
        };
        update(Si, Sj, 0);
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second; q.pop();
            rep(dir, 4) {
                int ni = i+di[dir], nj = j+dj[dir];
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, H)rep(j, W) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << ednl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: expected ',' or ';' before 'queue'
   20 |         queue<P> q;
      |         ^~~~~
a.cc: In lambda function:
a.cc:24:13: error: 'q' was not declared in this scope
   24 |             q.push(P(i, j));  // .emplace(i, j)
      |             ^
a.cc: In function 'int main()':
a.cc:27:17: error: 'q' was not declared in this scope
   27 |         while (!q.empty()) {
      |                 ^
a.cc:42:20: error: 'ednl' was not declared in this scope
   42 |     cout << ans << ednl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
#include <algorithm>
 using namespace std;
typedef pair<int,int>P;
const int INF=100000000;
 char S[22][22]
  int H,W;

int d[22][22];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs(int sx,int sy,int gx,int gy){
queue<P>que;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)d[i][j]=INF;
  que.push(P(sx,sy));
  d[sx][sy]=0;
  while(que.size()){
  P p=que.front();que().pop();
    if(p.first==gx && p.second == gy)break;
    for(int int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+sy[i];
      if(0<=nx && nx<H&& 0<=ny&&ny<W&&S[nx][ny]!='#'&&d[nx][ny]==INF){
        que.push(P(ne,ny));
        d[nx][ny]=d[p.first][p.second]+1:
      }
    }
  }
  return d[gx][gy];
}
  

int main(){

  cin>>H>>W;
 
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>S[i][j];
    }
  }
  

Compiler output:
a.cc:7:3: error: expected initializer before 'int'
    7 |   int H,W;
      |   ^~~
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:13:17: error: 'H' was not declared in this scope
   13 |   for(int i=0;i<H;i++)
      |                 ^
a.cc:14:19: error: 'W' was not declared in this scope
   14 |     for(int j=0;j<W;j++)d[i][j]=INF;
      |                   ^
a.cc:18:22: error: no match for call to '(std::queue<std::pair<int, int> >) ()'
   18 |   P p=que.front();que().pop();
      |                   ~~~^~
a.cc:20:9: error: two or more data types in declaration of 'i'
   20 |     for(int int i=0;i<4;i++){
      |         ^~~
a.cc:20:21: error: 'i' was not declared in this scope
   20 |     for(int int i=0;i<4;i++){
      |                     ^
a.cc:22:22: error: 'H' was not declared in this scope
   22 |       if(0<=nx && nx<H&& 0<=ny&&ny<W&&S[nx][ny]!='#'&&d[nx][ny]==INF){
      |                      ^
a.cc:22:29: error: 'ny' was not declared in this scope; did you mean 'nx'?
   22 |       if(0<=nx && nx<H&& 0<=ny&&ny<W&&S[nx][ny]!='#'&&d[nx][ny]==INF){
      |                             ^~
      |                             nx
a.cc:22:36: error: 'W' was not declared in this scope
   22 |       if(0<=nx && nx<H&& 0<=ny&&ny<W&&S[nx][ny]!='#'&&d[nx][ny]==INF){
      |                                    ^
a.cc:22:39: error: 'S' was not declared in this scope
   22 |       if(0<=nx && nx<H&& 0<=ny&&ny<W&&S[nx][ny]!='#'&&d[nx][ny]==INF){
      |                                       ^
a.cc:23:20: error: 'ne' was not declared in this scope; did you mean 'nx'?
   23 |         que.push(P(ne,ny));
      |                    ^~
      |                    nx
a.cc: In function 'int main()':
a.cc:34:8: error: 'H' was not declared in this scope
   34 |   cin>>H>>W;
      |        ^
a.cc:34:11: error: 'W' was not declared in this scope
   34 |   cin>>H>>W;
      |           ^
a.cc:38:12: error: 'S' was not declared in this scope
   38 |       cin>>S[i][j];
      |            ^
a.cc:40:4: error: expected '}' at end of input
   40 |   }
      |    ^
a.cc:32:11: note: to match this '{'
   32 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

void search(int *m, int *r, int h, int w, int c, int g, int d){
    if(r[c] > d){
        r[c] = d;
    }
    if(c == g || r[g] <= d){
        return;
    }

    //move right
    if(c%w != (w-1) && m[c+1] && r[c+1] > d+1){
        search(m, r, h, w, c+1, g, d+1);
    }
    
    //move left
    if(c%w != 0 && m[c-1] && r[c-1] > d+1){
        search(m, r, h, w, c-1, g, d+1);
    }

    //move upper
    if((c-w) >= 0 && m[c-w] && r[c-w] > d+1){
        search(m, r, h, w, c-w, g, d+1);
    }

    //move lower
    if((c+w) < h*w && m[c+w] && r[c+w] > d+1){
        search(m, r, h, w, c+w, g, d+1);
    }
    
}

int main(){
    int h, w;
    cin >> h >> w;

    int m[h*w];
    for(int i=0; i < h; i++){
        string line;
        cin >> line;
        for(int j=0; j < w; j++){
            if(line[j] == '.'){
                m[i*w+j] = 1;
            }else{
                m[i*w+j] = 0;
            }
        }
    }

    int r[h*w];
    int max = 0;
    for(int i=0; i < h*w; i++){
        for(int j=i+1; j < h*w; j++){
            for(int k=0; k < h*w; k++){
                r[k] = INT_MAX;
            }
            if(m[i] == 0 || m[j] == 0){
                    continue;
            }
            search(m, r, h, w, i, j, 0);
            if(r[j] > max){
                max = r[j];
            }
        }
    }
    cout << max << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:24: error: 'INT_MAX' was not declared in this scope
   56 |                 r[k] = INT_MAX;
      |                        ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>p;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	rep(i, h)cin >> s[i];
	int ans = 0;
	rep(si, h)rep(sj, w) {
		if (s[si][sj] == '#')continue;
		vector<vector<int>> dist(h, vector<int>(w, INF));
		queue<p>q;
		auto update = [&](int i, int j, int x) {
			if (dist[i][j] != INF)return;
			dist[i][j] = x;
			q.push(P(i, j));
		};
		update(si, sj, 0);
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			rep(dir, 4) {
				int ni = i + di[dir], nj = j + dj[dir];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == '#')continue;
				update(ni, nj, dist[i][j] + 1);
			}
		}
		rep(i, h)rep(j, w) {
			if (dist[i][j] == INF)continue;
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:28:32: error: 'P' was not declared in this scope
   28 |                         q.push(P(i, j));
      |                                ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>p;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	rep(i, h)cin >> s[i];
	int ans = 0;
	rep(si, h)rep(sj, w) {
		if (s[si][sj] == '#')continue;
		vector<vector<int>> dist(h, vector<int>(w, INF));
		queue<p>q;
		auto update = [&](int i, int j, int x) {
			if (dist[i][j] != INF)return;
			dist[i][j] = x;
			q.push(P(i, j));
		};
		update(si, sj, 0);
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			rep(dir, 4) {
				int ni = i + di[dir], nj = j + dj[dir];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == "#")continue;
				update(ni, nj, dist[i][j] + 1);
			}
		}
		rep(i, h)rep(j, w) {
			if (dist[i][j] == INF)continue;
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:28:32: error: 'P' was not declared in this scope
   28 |                         q.push(P(i, j));
      |                                ^
a.cc: In function 'int main()':
a.cc:38:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   38 |                                 if (s[ni][nj] == "#")continue;
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>p;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	rep(i, h)cin >> s[i];
	rep(si, h)rep(sj, w) {
		if (s[si][sj] == "#")continue;
		vector<vector<int>> dist(h, vector<int>(w, INF));
		queue<p>q;
		auto update = [&](int i, int j, int x) {
			if (dist[i][j] != INF)return;
			dist[i][j] = x;
			q.push(P(i, j));
		};
		update(si, sj, 0);
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			rep(dir, 4) {
				int ni = i + di[dir], nj = j + dj[dir];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == "#")continue;
				update(ni, nj, dist[i][j] + 1);
			}
		}
		rep(i, h)rep(j, w) {
			if (dist[i][j] == INF)continue;
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   21 |                 if (s[si][sj] == "#")continue;
a.cc: In lambda function:
a.cc:27:32: error: 'P' was not declared in this scope
   27 |                         q.push(P(i, j));
      |                                ^
a.cc: In function 'int main()':
a.cc:37:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |                                 if (s[ni][nj] == "#")continue;
a.cc:43:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |                         ans = max(ans, dist[i][j]);
      |                         ^~~
      |                         abs
a.cc:46:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>p;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	intt h, w;
	cin >> h >> w;
	vector<string>s(h);
	rep(i, h)cin >> s[i];
	rep(si, h)rep(sj, w) {
		if (s[si][sj] == "#")continue;
		vector<vector<int>> dist(h, vector<int>(w, INF));
		queue<p>q;
		auto update = [&](int i, int j, int x) {
			if (dist[i][j] != INF)return;
			dist[i][j] = x;
			q.push(P(i, j));
		};
		update(si, sj, 0);
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			rep(dir, 4) {
				int ni = i + di[dir], nj = j + dj[dir];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == "#")continue;
				update(ni, nj, dist[i][j] + 1);
			}
		}
		rep(i, h)rep(j, w) {
			if (dist[i][j] == INF)continue;
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'intt' was not declared in this scope; did you mean 'int'?
   16 |         intt h, w;
      |         ^~~~
      |         int
a.cc:17:16: error: 'h' was not declared in this scope
   17 |         cin >> h >> w;
      |                ^
a.cc:17:21: error: 'w' was not declared in this scope
   17 |         cin >> h >> w;
      |                     ^
a.cc:21:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   21 |                 if (s[si][sj] == "#")continue;
a.cc: In lambda function:
a.cc:27:32: error: 'P' was not declared in this scope
   27 |                         q.push(P(i, j));
      |                                ^
a.cc: In function 'int main()':
a.cc:37:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |                                 if (s[ni][nj] == "#")continue;
a.cc:43:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |                         ans = max(ans, dist[i][j]);
      |                         ^~~
      |                         abs
a.cc:46:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
const int p[]={-1,0,1,0};
const int v[]={0,-1,0,1};

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  int ans=0;
  
  rep(i,h)rep(j,w){
      if(s[i][j]=='#') continue;
      vector<vector<int>> d(h,vector<int>(w,-1));
      queue<P> wa;

      auto kyu=[&](int a, int b, int x){
          if(d[a][b]!='-1') return;
          d[a][b] = x;
          wa.push(P(a,b));
      };
      
      kyu(i,j,0);
      while(!wa.empty()){
          int nowi=wa.front().first;
          int nowj=wa.front().second;
          wa.pop();
         rep(dir,4){
             int ni=nowi+p[dir]; int nj=nowj+v[dir];
             if(ni<0||ni>=h||nj<0||nj>=w) continue;
             if(s[ni][nj]=='#') continue;
             if(d[ni][nj]==-1) continue;
             kyu(ni,nj,d[nowi][nowj]+1)
         }
      }
    rep(aa,h)rep(bb,w){
        ans=max(ans,d[aa][bb]);
    }
  }
  cout << ans << endl;
 return 0;
}


Compiler output:
a.cc:23:23: warning: multi-character character constant [-Wmultichar]
   23 |           if(d[a][b]!='-1') return;
      |                       ^~~~
a.cc: In function 'int main()':
a.cc:38:40: error: expected ';' before '}' token
   38 |              kyu(ni,nj,d[nowi][nowj]+1)
      |                                        ^
      |                                        ;
   39 |          }
      |          ~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
const int p[]={-1,0,1,0};
const int v[]={0,-1,0,1};

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  int ans=0;
  
  rep(i,h)rep(j,w){
      if(s[i][j]=='#') continue;
      vector<vector<int>> d(h,vector<int>(w,-1));
      queue<P> wa;

      auto kyu=[&](int a, int b, int x){
          if(d[a][b]!='-1') return;
          d[a][b] = x;
          wa.push(P(a,b));
      }
      
      kyu(i,j,0);
      while(!wa.empty()){
          int nowi=wa.front().first;
          int nowj=wa.front().second;
          wa.pop();
         rep(dir,4){
             int ni=nowi+p[dir]; int nj=nowj+v[dir];
             if(ni<0||ni>=h||nj<0||nj>=w) continue;
             if(s[ni][nj]=='#') continue;
             if(d[ni][nj]==-1) continue;
             kyu(ni,nj,d[nowi][nowj]+1)
         }
      }
    rep(aa,h)rep(bb,w){
        ans=max(ans,d[aa][bb]);
    }
  }
  cout << ans << endl;
 return 0;
}


Compiler output:
a.cc:23:23: warning: multi-character character constant [-Wmultichar]
   23 |           if(d[a][b]!='-1') return;
      |                       ^~~~
a.cc: In function 'int main()':
a.cc:28:7: error: expected ',' or ';' before 'kyu'
   28 |       kyu(i,j,0);
      |       ^~~
a.cc:38:40: error: expected ';' before '}' token
   38 |              kyu(ni,nj,d[nowi][nowj]+1)
      |                                        ^
      |                                        ;
   39 |          }
      |          ~
Language: C++

#include <iostream>
#include <queue>
using namespace std;

const int MAXN=20+1;
const int MAXM=20+1;

int n,m;
char mp[MAXN][MAXM];
int ans[MAXN][MAXM];

struct q_node
{
	int x,y,num;
};

int dx[4+1]={0,0,1,0,-1};
int dy[4+1]={0,1,0,-1,0};

void bfs(int x,int y)
{
	int vis[MAXN][MAXM];
	memset(vis,0,sizeof(vis));
	queue<q_node> q;
	
	q_node head;
	head.x=x,head.y=y,head.num=0;
	vis[x][y]=1;
	q.push(head);
	
	while(!q.empty())
	{
		q_node tmp=q.front();
		for(int i=1; i<=4; i++)
		{
			q_node next;
			next.x=tmp.x+dx[i];
			next.y=tmp.y+dy[i];
			next.num=tmp.num+1;
			
			if(next.x<=n && next.x>=1&& next.y<=m && next.y>=1
			&& !vis[next.x][next.y]&& mp[next.x][next.y]=='.')
			{
				vis[next.x][next.y]=1;
				q.push(next);
				ans[next.x][next.y]=max(ans[next.x][next.y],next.num)
			}
		}
		
		q.pop();
	}
}

int main()
{
	cin>>n>>m;
	
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>mp[i][j];
	
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			if(mp[i][j]=='.')
				bfs(i,j);
				
	int res=0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			res=max(res,ans[i][j]);
	
	cout<<res<< endl;
	return 0;
}

Compiler output:
a.cc: In function 'void bfs(int, int)':
a.cc:23:9: error: 'memset' was not declared in this scope
   23 |         memset(vis,0,sizeof(vis));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc:46:86: error: expected ';' before '}' token
   46 |                                 ans[next.x][next.y]=max(ans[next.x][next.y],next.num)
      |                                                                                      ^
      |                                                                                      ;
   47 |                         }
      |                         ~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(void) {
    long h, w;
    cin >> h >> w;

    vector<string> m(h);
    for(auto &e: m) cin >> e;

    auto f = [&](long i) {
        return m[i/w][i%w] == '.';
    };

    vector<vector<long>> d(h*w, vector<long>(h*w, 1e9));
    for(long i=0; i<h*w; i++) {
        d[i][j] = 0;
        if(!f(i)) continue;
        if(i+w < h*w && f(i+w))
            d[i+w][i] = d[i][i+w] = 1;
        if(i-w >= 0 && f(i-w))
            d[i-w][i] = d[i][i-w] = 1;
        if((i+1)/w == i/w && f(i+1))
            d[i+1][i] = d[i][i+1] = 1;
        if(i-1 >= 0 && (i-1)/w == i/w && f(i-1))
            d[i-1][i] = d[i][i-1] = 1;
    }

    for(long k=0; k<h*w; k++)
        for(long i=0; i<h*w; i++)
            for(long j=0; j<h*w; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    long r = 0;
    for(long i=0; i<h*w; i++)
        for(long j=0; j<h*w; j++)
            if(d[i][j] < 1e9)
                r = max(r, d[i][j]);
    cout << r << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'j' was not declared in this scope
   17 |         d[i][j] = 0;
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int n, m;
int d[maxn][maxn];
char s[maxn][maxn];
int main() {
	scanf("%d%d", &n, &m);
	memset(a, -1, sizeof(a));
	for(int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
	}
	int ans = 0;
	queue<int> q;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			memset(d, -1, sizeof(d));
			d[i][j] = 0;
			q.push(i);
			q.push(j);
			while(!q.empty()) {
				int x = q.front(); q.pop();
				int y = q.front(); q.pop();
				for(int k = 0; k < 4; ++k) {
					int xx = x + dx[k], yy = y + dy[k];
					if(s[xx][yy] == '.' && d[xx][yy] == -1) {
						q.push(xx);
						q.push(yy);
						d[xx][yy] = d[x][y] + 1;
					}
				}
			}
			for(int x = 1; x <= n; ++x) {
				for(int y = 1; y <= m; ++y) {
					ans = max(ans, d[x][y]);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: 'a' was not declared in this scope
   10 |         memset(a, -1, sizeof(a));
      |                ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1e6;
const int di = {-1,0,1,0};
const int dj = {0,-1,0,1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dish(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dish[i][j] != INF) return;
            dish[i][j] = x;
            q.push(P(i,j));
        };
        update(si,sj,0);
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second; q.pop();
            rep(dir,4) {
                int ni = i + di[dir], nj = j + dj[dir];
                if (ni < 0 || ni > h || nj < 0 || nj > w) continue;
                if (s[ni][nj] == '#') continue;
                update(ni,nj,dish[i][j] + 1);
            }
        }
        rep(i,h)rep(j,w) {
            if (dish[i][j] == INF) continue;
            ans = max(ans, dish[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc:8:11: error: scalar object 'di' requires one element in initializer
    8 | const int di = {-1,0,1,0};
      |           ^~
a.cc:9:11: error: scalar object 'dj' requires one element in initializer
    9 | const int dj = {0,-1,0,1};
      |           ^~
a.cc: In function 'int main()':
a.cc:33:41: error: 'nj' was not declared in this scope; did you mean 'ni'?
   33 |                 if (ni < 0 || ni > h || nj < 0 || nj > w) continue;
      |                                         ^~
      |                                         ni
a.cc:34:27: error: 'nj' was not declared in this scope; did you mean 'ni'?
   34 |                 if (s[ni][nj] == '#') continue;
      |                           ^~
      |                           ni
a.cc:35:27: error: 'nj' was not declared in this scope; did you mean 'ni'?
   35 |                 update(ni,nj,dish[i][j] + 1);
      |                           ^~
      |                           ni
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll

typedef queue<pair<int,int>> Q;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
inline int in() {int x; cin >> x; return x;}
const int INF = 1e+9;

int h, w;
vs s;
int dirh = {0,-1,0,+1}, dirw = {-1,0,+1,0};
int ans = 0;

void bfs(int h1, int w1) {
  vvi dist(h, vi(w, INF));
  Q q;
  q.push({h1,w1})
  while (!q.empty()) {
    int h2, w2; tie(h2,w2) = q.front; q.pop();
    FOR (d,0,4) {
      int h3 = h2 + dirh[d];
      int w3 = w2 + dirw[d];

      if (!(0<=h3 && h3<=h && 0<=w3 && w3<=w)) continue;
      if (s[h3][w3]=='#') continue;
      if (dist[h3][w3]!=INF) continue;

      dist[h3][w3] = dist[q2][q2] + 1;
      q.push({h3,w3});
    }
  }

  FOR (i,0,h) {
    FOR (j,0,w) {
      if (dist[i][j]==INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
}
void solve() {
  h = in();
  w = in();
  s.resize(h);
  FOR (i,0,h) cin >> s[h];

  FOR (i,0,h) {
    FOR (j,0,w) {
      if (s[i][j]=='#') continue;
      bfs(i,j);
    }
  }

  cout << ans << endl;
}

#undef int
int main() {
  solve();
}

Compiler output:
a.cc:17:5: error: scalar object 'dirh' requires one element in initializer
   17 | int dirh = {0,-1,0,+1}, dirw = {-1,0,+1,0};
      |     ^~~~
a.cc:17:25: error: scalar object 'dirw' requires one element in initializer
   17 | int dirh = {0,-1,0,+1}, dirw = {-1,0,+1,0};
      |                         ^~~~
a.cc: In function 'void bfs(ll, ll)':
a.cc:23:18: error: expected ';' before 'while'
   23 |   q.push({h1,w1})
      |                  ^
      |                  ;
   24 |   while (!q.empty()) {
      |   ~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m, res = 0;
    cin >> n >> m;
    vector<vector<bool>> a(n + 2, vector<bool>(m + 2));
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
            a[i + 1][j + 1] = (s[j] == '.');
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            vector<vector<int>> d(n, vector<int>(m, INT_MAX));
            d[i][j] = 0;
            vector<pair<int, int>> q;
            q.emplace_back(i, j);
            for (int k = 0; k < q.size(); k++)
            {
                auto p = q[k];
                int x = p.first;
                int y = p.second;
                res = max(res, d[x][y]);
                vector<int> dx = {-1, 0, 0, 1};
                vector<int> dy = {0, -1, 1, 0};
                for (int dir = 0; dir < 4; dir++)
                {
                    int xx = x + dx[dir];
                    int yy = y + dy[dir];
                    if (a[xx + 1][yy + 1] && d[xx][yy] == INT_MAX)
                    {
                        d[xx][yy] = d[x][y] + 1;
                        q.emplace_back(xx, yy);
                    }
                }
            }
        }

    cout << res << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:53: error: 'INT_MAX' was not declared in this scope
   28 |             vector<vector<int>> d(n, vector<int>(m, INT_MAX));
      |                                                     ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 |
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

int h, w;
char m[21][21];
queue< pair<int, int> > path;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { -1,1,0,0 };
int cache[21][21] = { 0, };

int solv(int idx1,int idx2) {
	int max(0);
	cache[idx1][idx2] = 1;
	while (!path.empty())
	{
		idx1 = path.front().first;
		idx2 = path.front().second;
		path.pop();
		for (int i = 0; i < 4; i++) {
			int ny = idx1 + dy[i];
			int nx = idx2 + dx[i];
			if (0 <= ny && ny < h && 0 <= nx < w 
				&& !cache[ny][nx]) {
				if (m[ny][nx] == '.') {
					path.push({ ny,nx });
					cache[ny][nx] = cache[idx1][idx2] + 1;
					if (max < cache[ny][nx])
						max = cache[ny][nx];
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		memset(cache[i], 0, w * sizeof(int));
	}
	return max;
}

int main()
{
	cin >> h >> w;
	int maximum(0);
	for(int i=0;i<h;i++)
		for (int j = 0; j < w; j++) {
			cin >> m[i][j];
		}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '.') {
				path.push({ i,j });
				int tmp = solv(i, j);
				maximum = max(tmp,maximum);
			}
		}
	}
	cout << maximum-1;
	return 0;
}

Compiler output:
a.cc: In function 'int solv(int, int)':
a.cc:37:17: error: 'memset' was not declared in this scope
   37 |                 memset(cache[i], 0, w * sizeof(int));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

int h, w;
char m[21][21];
queue< pair<int, int> > path;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { -1,1,0,0 };
int cache[21][21] = { 0, };

int solv(int idx1,int idx2) {
	int max(0);
	cache[idx1][idx2] = 1;
	while (!path.empty())
	{
		idx1 = path.front().first;
		idx2 = path.front().second;
		path.pop();
		for (int i = 0; i < 4; i++) {
			int ny = idx1 + dy[i];
			int nx = idx2 + dx[i];
			if (0 <= ny && ny < h && 0 <= nx < w 
				&& !cache[ny][nx]) {
				if (m[ny][nx] == '.') {
					path.push({ ny,nx });
					cache[ny][nx] = cache[idx1][idx2] + 1;
					if (max < cache[ny][nx])
						max = cache[ny][nx];
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		memset(cache[i], 0, w * sizeof(int));
	}
	return max;
}

int main()
{
	cin >> h >> w;
	int maximum(0);
	for(int i=0;i<h;i++)
		for (int j = 0; j < w; j++) {
			cin >> m[i][j];
		}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '.') {
				path.push({ i,j });
				
				maximum = max(solv(i,j),maximum);
			}
		}
	}
	cout << maximum-1;
	return 0;
}

Compiler output:
a.cc: In function 'int solv(int, int)':
a.cc:37:17: error: 'memset' was not declared in this scope
   37 |                 memset(cache[i], 0, w * sizeof(int));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

char S[25][25];
bool visited[25][25];
int H, W;
int mx = 0;
int dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

struct node {
	int x, y, t;
	node(int x_, int y_, int t_) {
		x = x_;
		y = y_;
		t = t_;
	}
};

void dfs(int x, int y) {
	memset(visited, false, sizeof(visited));
	queue<node> q;
	node n = node(x, y, 0);
	q.push(n);
	visited[x][y] = true;

	while (!q.empty()) {
		node now = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int x2 = now.x + dir[i][0];
			int y2 = now.y + dir[i][1];
			if (0 <= x2 && x2 < H && 0 <= y2 && y2 < W && !visited[x2][y2] && S[x2][y2] != '#') {
				node next = node(x2, y2, now.t + 1);
				q.push(next);
				visited[x2][y2] = true;
				mx = max(mx, now.t + 1);
			}
		}
	}
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				continue;
			}
			dfs(i, j);
		}
	}
	cout << mx << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:23:9: error: 'memset' was not declared in this scope
   23 |         memset(visited, false, sizeof(visited));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	size_t size = sizeof(visit);
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		bool visit[20][20] = { 0 };

		P s = make_pair(sy, sx);

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
	}
	
	cout << max << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: 'visit' was not declared in this scope
   26 |         size_t size = sizeof(visit);
      |                              ^~~~~
a.cc:4:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
    3 | #include <queue>
  +++ |+#include <variant>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	bool visit[20][20] = { 0 };
	size_t size = sizeof(visit);
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		memset(visit, false, size);

		P s = make_pair(sy, sx);

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
	}
	
	cout << max << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'memset' was not declared in this scope
   34 |                 memset(visit, false, size);
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | using namespace std;