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

#include <bits/stdc++.h>
using namespace std;
char G[44][44];
int vis[44][44]={0};
int h,w;
int inbound(int i,int j){
    return i>0&&j>0&&i<=h&&j<=w&&G[i][j]=='.';
}
struct node{
    int a,b,c;
};
int a[4][2]={0,1,-1,0,0,-1,1,0};
int solve(int z,int c){
    int ret = 0 ;
    memset(vis,0,sizeof vis);

    queue<node>qq;
    qq.push({z,c,0});
    visit[z][c]=1;
    while(!qq.empty()){
        int x = qq.front().a;
        int y = qq.front().b;
        int len = qq.front().c;
        qq.pop();
        ret=max(ret,len);
        for(int i=0;i<4;i++){
            int x1= x+a[i][0];
            int y1= y+a[i][1];
            if(inbound(x1,y1)&&!vis[x1][y1]){
                vis[x1][y1]=1;
                qq.push({x1,y1,len+1});
            }
        }
    }
}
int main()
{

    cin  >> h>>w;
    for(int i=1;i<=h;i++){
        cin >>G[i]+1;
    }
    //visit[1][1]=1;
    int res = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
            res = max(res,solve(i,j));
    }
    cout << res <<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:19:10: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   19 |     visit[z][c]=1;
      |          ^
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
Language: C++

#include <stdio.h>
#include <queue>
using namespace std;

int n,m; char map[22][22]; int d[22][22];
int bfs(int sx, int sy)
{
for (int i=0;i<n;i++) for (int j=0;j<m;j++) d[i][j] = -1;
queue<pair<int, int> > q; q.push({sx,sy}); d[sx][sy] = 0;
  int r = 0;
  while (!q.empty()){
int x = q.front().first, y = q.front().second; r = d[x][y];
    int dx[4] = {0,1,0,-1};
    int dy[4] = {1,0,-1,0};
    for(int k=0;k<4;k++){
int px = x + dx[k], py = y + dy[k];
      if (px < 0 || px >= n || py < 0 || py >= m || map[px][py] == '#') continue;
      if (d[px][py] == -1){
q.push({px,py}); d[px][py] = d[x][y] + 1;
      }
    }
  }
  return r;
}

int main()
{
scanf ("%d %d",&n,&m);
  for (int i=0;i<n;i++) scnaf ("%s",map[i]);
  int ans = 0;
  for (int i=0;i<n;i++) for (int j=0;j<m;j++) if (map[i][j] == '.'){
int a = bfs(i,j);
    if (ans < a) ans = a;
  }
  printf ("%d\n",ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:25: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
   29 |   for (int i=0;i<n;i++) scnaf ("%s",map[i]);
      |                         ^~~~~
      |                         scanf
Language: C++

#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <cstdio>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 9)
#define INF (1 << 29)

int a[MAXN][MAXN];

int h, w;
int m[MAXN][MAXN];
int n;

int ind(int x, int y) {
	return (x - 1) * w + (y - 1);
}

void addedge(int cur, int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int nnext = ind(x, y);
	a[cur][nnext] = 1;
	a[nnext][cur] = 1;

}

void addedges(int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int cur = ind(x,y);
	addedge(cur, x + 1, y);
	addedge(cur, x - 1, y);
	addedge(cur, x, y - 1);
	addedge(cur, x, y + 1);
}

void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] > a[i][k] + a[k][j]) {
					a[i][j] = a[i][k] + a[k][j];
				}
			}
		}
	}
}

int main() {
	memset(a, 63, sizeof(a));
	scanf("%d %d\n", &h, &w);
	for (int i = 1; i <= h; i++) {
		char s[MAXN];
		gets(s);
		for (int j = 1; j <= w; j++) {
			if (s[j - 1] == '.') {
				m[i][j] = 1;
			} 
		}
	}
	n = h * w;
	for (int i = 0; i < n; i++) {
		a[i][i] = 0;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			addedges(i, j);
		}
	}
	floyd();	
	
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if ((a[i][j] < INF) && (a[i][j] > ret)) {
				ret = a[i][j];
			}
		}
	}
	cout << ret << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   74 |                 gets(s);
      |                 ^~~~
      |                 getw
Language: C++

#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 9)
#define INF (1 << 29)

int a[MAXN][MAXN];

int h, w;
int m[MAXN][MAXN];
int n;

int ind(int x, int y) {
	return (x - 1) * w + (y - 1);
}

void addedge(int cur, int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int nnext = ind(x, y);
	a[cur][nnext] = 1;
	a[nnext][cur] = 1;

}

void addedges(int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int cur = ind(x,y);
	addedge(cur, x + 1, y);
	addedge(cur, x - 1, y);
	addedge(cur, x, y - 1);
	addedge(cur, x, y + 1);
}

void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] > a[i][k] + a[k][j]) {
					a[i][j] = a[i][k] + a[k][j];
				}
			}
		}
	}
}

int main() {
	memset(a, 63, sizeof(a));
	scanf("%d %d\n", &h, &w);
	for (int i = 1; i <= h; i++) {
		char s[MAXN];
		gets(s);
		for (int j = 1; j <= w; j++) {
			if (s[j - 1] == '.') {
				m[i][j] = 1;
			} 
		}
	}
	n = h * w;
	for (int i = 0; i < n; i++) {
		a[i][i] = 0;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			addedges(i, j);
		}
	}
	floyd();	
	
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if ((a[i][j] < INF) && (a[i][j] > ret)) {
				ret = a[i][j];
			}
		}
	}
	cout << ret << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   74 |                 gets(s);
      |                 ^~~~
      |                 getw
Language: C++

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

int main() {
    int h,w;
    cin >>> h >> w;
    vector<vector<char>> mp(h,vector<char>(w));
    char s;
    rep(i,h){
        rep(j,w){
            cin >> s;
            mp[i][j] = s;
        }
    }
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(mp[i][j]=='#') continue;
            queue<pair<int,int>> que;
            vector<V> dist(h,V(w,-1));
            dist[i][j] = 0;
            que.push(make_pair(i,j));
            while(!que.empty()){
                int x = que.front().first, y = que.front().second;
                que.pop();
                if(x>0&&dist[x-1][y]==-1&&mp[x-1][y]=='.'){
                    dist[x-1][y] = dist[x][y] + 1;
                    que.push(make_pair(x-1,y));
                    ans = max(ans,dist[x-1][y]);
                }
                if(y>0&&dist[x][y-1]==-1&&mp[x][y-1]=='.'){
                    dist[x][y-1] = dist[x][y] + 1;
                    que.push(make_pair(x,y-1));
                    ans = max(ans,dist[x][y-1]);
                }
                if(x<h-1&&dist[x+1][y]==-1&&mp[x+1][y]=='.'){
                    dist[x+1][y] = dist[x][y] + 1;
                    que.push(make_pair(x+1,y));
                    ans = max(ans,dist[x+1][y]);
                }
                if(y<w-1&&dist[x][y+1]==-1&&mp[x][y+1]=='.'){
                    dist[x][y+1] = dist[x][y] + 1;
                    que.push(make_pair(x,y+1));
                    ans = max(ans,dist[x][y+1]);
                }
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: expected primary-expression before '>' token
   12 |     cin >>> h >> w;
      |           ^
Language: C++

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>>s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cin>>s[i][j];
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      vector<vector<int>>distance(h,vector<int>(w));
      vector<vector<bool>>a(h,vector<bool>(w));
      queue<int>q;
      q.push(i);
      q.push(j);
      if(s[i][j]=='#') break;
      else{
        while(!queue.empty()){
          int f=q.front();
          q.pop();
          int g=q.front();
          q.pop();
          if((f-1>=0 && ! a[f-1][g]) && s[f-1][g]=='.'){
            int c=distance[f][g]+1;
            ans=max(ans,c);
            distance[f-1][g]=c;
            a[f-1][g]=true;
            q.push(f-1);
            q.push(g);
            
          }
          if((f+1<=n-1 && ! a[f+1][g]) && s[f+1][j]=='.'){
            int c=distance[f][g]+1;
            ans=max(ans,c);
            distance[f+1][g]=c;
            a[f+1][g]=true;
            q.push(f+1);
            q.push(g);
          }
          if((g-1>=0 && ! a[f][g-1]) && s[f][g-1]=='.'){
            int c=distance[f][g]+1;
            ans=max(ans,c);
            distance[f][g-1]=c;
            a[f][g-1]=true;
            q.push(f);
            q.push(g-1);
          }
          if((g+1<=n-1 && ! a[f][g+1]) && s[f][g+1]=='.'){
            int c=distance[f][g]+1;
            ans=max(ans,c);
            distance[f][g+1]=c;
            a[f][g+1]=true;
            q.push(f);
            q.push(g+1);
          }
        }
      }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: missing template arguments before '.' token
   21 |         while(!queue.empty()){
      |                     ^
a.cc:35:20: error: 'n' was not declared in this scope
   35 |           if((f+1<=n-1 && ! a[f+1][g]) && s[f+1][j]=='.'){
      |                    ^
a.cc:51:20: error: 'n' was not declared in this scope
   51 |           if((g+1<=n-1 && ! a[f][g+1]) && s[f][g+1]=='.'){
      |                    ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;

using namespace std;

int dx[] = {1,-1, 0, 0};
int dy[] = {0, 0,-1, 1};
int d[500][500];

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int h,w; cin >> h >> w; int N = h * w;
      

      char s[h][w];
      rep(i,h)rep(j,w) cin >> s[i][j];

      rep(i,500)rep(j,500) d[i][j] = 1000;
      rep(i,500) dp[i][i] = 0;
      rep(i,h)rep(j,w){
            if(s[i][j] == '#') continue;
            int num = i * w + j;
            rep(k,4){
                  int nx = i + dx[k], ny = j + dy[k];
                  if(nx < 0 || ny < 0 || nx >= h || ny >= w || s[nx][ny] == '#') continue;
                  int num2 = nx * w  + ny;
                  d[num][num2] = 1;
                  d[num2][num] = 1;
            }
      }

      
      rep(i,N)rep(j,N)rep(k,N) chmin(d[j][k], d[j][i] + d[i][k]);

      int ans = 0;
      rep(i,N)rep(j,N) if(d[i][j]< 1000) chmax(ans,d[i][j]);

      cout << ans << endl;

      return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:18: error: 'dp' was not declared in this scope; did you mean 'dy'?
   27 |       rep(i,500) dp[i][i] = 0;
      |                  ^~
      |                  dy
Language: C++

#include <bits/stdc++.h>
#define N 25
#define M 25
using namespace std;
int n,m;
int dis[N][M];
int mx[4]={-1,1,0,0};
int my[4]={0,0,1,-1};
char map1[N][M];

void bs(int y, int x, int sy,int sx){
  for(int i=0;i<4;i++){
    int ny = y+my[i], nx = x+mx[i];
    if(sy == ny && sx == nx) continue;
    if(ny >=0 && nx >=0 && ny <n && nx <m ){
      if(map1[ny][nx] == '.'){
        if(dis[ny][nx] == 0 || (dis[ny][nx] > dis[y][x] +1)){
          dis[ny][nx] = dis[y][x] + 1;
          bs(ny,nx,sy,sx);
        }
      }
    }
  }
}
  

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>map1[i][j];
    }
  }
  for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          dis[i][j] = 0;
        }
      }
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(mp1[i][j]=='#') continue;
      bs(i,j,i,j);
      int maxnum = 0;
      for(int k=0;k<n;k++){
        for(int l=0;l<m;l++){
          if(dis[k][l]>maxnum) maxnum = dis[k][l];
          dis[k][l] = 0;
        }
      }
      if(ans<maxnum) ans = maxnum;
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:10: error: 'mp1' was not declared in this scope; did you mean 'map1'?
   42 |       if(mp1[i][j]=='#') continue;
      |          ^~~
      |          map1
Language: C++

#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

int mai=0;



void bfs(int x, int y, vector<string>s){
	if(s[i][j]=='#') return;
	
	map<ii,int>ma;

	int i,j,e;
	pair<int,int>aux;


	queue<pair<int,pair<int,int>>>q;
	q.push(make_pair(0,make_pair(x,y)));

	while(q.empty()==false){
		
		i = q.front().second.first;
		j = q.front().second.second;
		e = q.front().first;
		aux = make_pair(i,j);

		if(ma[aux]!=0){
			q.pop();
			continue;
		}

		
		q.pop();

		mai = max(e, mai);
		ma[aux]++;


		if(s[i][j+1]=='.' and ma[make_pair(i,j+1)]==0){
			q.push(make_pair(e+1,make_pair(i,j+1)));
		}


		if(j!=0 and s[i][j-1]=='.' and ma[make_pair(i,j-1)]==0){
			q.push(make_pair(e+1,make_pair(i,j-1)));
		}


		if(s[i+1][j]=='.' and ma[make_pair(i+1,j)]==0){
			q.push(make_pair(e+1,make_pair(i+1,j)));
		}


		if(i!=0 and s[i-1][j]=='.' and ma[make_pair(i-1,j)]==0){
			q.push(make_pair(e+1,make_pair(i-1,j)));
		}

	}

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

	int n,m;
	string s;
	
	cin >> n >> m;
	vector<string>v(n+1);

	for(int i=0;i<n;i++){
		cin >> v[i];
		v[i].push_back('#');
	}

	for(int j=0;j<m;j++){
		v[n].push_back('#');
	}


	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			bfs(i,j,v);
		}
	}

	cout << mai << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void bfs(int, int, std::vector<std::__cxx11::basic_string<char> >)':
a.cc:20:14: error: 'i' was not declared in this scope
   20 |         if(s[i][j]=='#') return;
      |              ^
a.cc:20:17: error: 'j' was not declared in this scope
   20 |         if(s[i][j]=='#') return;
      |                 ^
Language: C++

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

int h, w;
char maze[20][20];
bool visited[20][20]={};

isValid(int left, int right){
    return (left>=0 && left<h && right>=0 && right<w && maze[left][right]=='.' && !visited[left][right]);
}

int solve(int x, int y){

    int count = 0;

    queue<pair<int,pair<int,int>>> q;
    visited[x][y] = true;
    q.push({0,{x,y}});
    bool flag = false;

    while(!q.empty()){

        pair<int,int> t = q.front().second;
        int dist = q.front().first;
        q.pop();

        flag=false;
        if(isValid(t.first+1, t.second)){
            visited[t.first+1][t.second]=true;
            q.push({dist+1,{t.first+1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first-1, t.second)){
            visited[t.first-1][t.second]=true;
            flag =true;
            q.push({dist+1,{t.first-1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second-1)){
            visited[t.first][t.second-1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second-1}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second+1)){
            visited[t.first][t.second+1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second+1}});
            count = max(count, dist+1);
        }

    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            visited[i][j]=false;
        }
    }
    return count;
}

int main(){

    cin >> h >> w;

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

    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j]=='.'){
                ans = max(ans, solve(i,j));
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Compiler output:
a.cc:8:1: error: ISO C++ forbids declaration of 'isValid' with no type [-fpermissive]
    8 | isValid(int left, int right){
      | ^~~~~~~
Language: C++

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

int h, w;
char maze[20][20];
bool visited[20][20]={};

isValid(int x, int y){
    return (x>=0 && x<h && y>=0 && y<w && maze[x][y]=='.' && !visited[x][y]);
}

int solve(int x, int y){

    int count = 0;

    queue<pair<int,pair<int,int>>> q;
    visited[x][y] = true;
    q.push({0,{x,y}});
    bool flag = false;

    while(!q.empty()){

        pair<int,int> t = q.front().second;
        int dist = q.front().first;
        q.pop();

        flag=false;
        if(isValid(t.first+1, t.second)){
            visited[t.first+1][t.second]=true;
            q.push({dist+1,{t.first+1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first-1, t.second)){
            visited[t.first-1][t.second]=true;
            flag =true;
            q.push({dist+1,{t.first-1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second-1)){
            visited[t.first][t.second-1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second-1}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second+1)){
            visited[t.first][t.second+1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second+1}});
            count = max(count, dist+1);
        }

    }
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            visited[i][j]=false;
        }
    }
    return count;
}

int main(){

    cin >> h >> w;

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

    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j]=='.'){
                ans = max(ans, solve(i,j));
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Compiler output:
a.cc:8:1: error: ISO C++ forbids declaration of 'isValid' with no type [-fpermissive]
    8 | isValid(int x, int y){
      | ^~~~~~~
Language: C++

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

int h, w;
char maze[20][20];
bool visited[20][20]={};

isValid(int x, int y){
    return (x>=0 && x<h && y>=0 && y<w && maze[x][y]=='.' && !visited[x][y]);
}

int solve(int x, int y){

    int count = 0;

    queue<pair<int,pair<int,int>>> q;
    visited[x][y] = true;
    q.push({0,{x,y}});
    bool flag = false;

    while(!q.empty()){

        pair<int,int> t = q.front().second;
        int dist = q.front().first;
        q.pop();

        flag=false;
        if(isValid(t.first+1, t.second)){
            visited[t.first+1][t.second]=true;
            q.push({dist+1,{t.first+1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first-1, t.second)){
            visited[t.first-1][t.second]=true;
            flag =true;
            q.push({dist+1,{t.first-1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second-1)){
            visited[t.first][t.second-1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second-1}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second+1)){
            visited[t.first][t.second+1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second+1}});
            count = max(count, dist+1);
        }

    }

    cout << count << "\n";
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            visited[i][j]=false;
        }
    }
    return count;
}

int main(){

    cin >> h >> w;

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

    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j]=='.'){
                ans = max(ans, solve(i,j));
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Compiler output:
a.cc:8:1: error: ISO C++ forbids declaration of 'isValid' with no type [-fpermissive]
    8 | isValid(int x, int y){
      | ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
char mat[22][22];
int n, m, res, in, jn, iv, jv;
const int di[] {0, 0, 1, -1};
const int dj[] {1, -1, 0, 0};
int main() {
    DAU
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> (mat[i] + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            vector<vector<int>> d(n + 1, vector<int>(m + 1, 0));
            d[i][j] = 0;
            queue<pair<int, int>> q;
            q.emplace(i, j);
            while (!q.empty()) {
                tie(in, jn) = q.front();
                q.pop();
                for (int dir = 0; dir < 4; ++dir) {
                    iv = in + di[dir];
                    jv = jn + dj[dir];
                    if (iv > 0 && jv > 0 && iv < n + 1 && jv < m + 1 && !d[iv][jv] && mat[iv][jv] == '.')
                        d[iv][jv] = d[in][jn] + 1, res = max(res, d[iv][jv]), q.emplace(iv, jv);
                }
            }
        }
    cout << res;
    PLEC
}


Compiler output:
a.cc:7:20: warning: built-in function 'jn' declared as non-function [-Wbuiltin-declaration-mismatch]
    7 | int n, m, res, in, jn, iv, jv;
      |                    ^~
a.cc: In function 'int main()':
a.cc:19:13: error: 'queue' was not declared in this scope
   19 |             queue<pair<int, int>> q;
      |             ^~~~~
a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    2 | #include <vector>
  +++ |+#include <queue>
    3 | #define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
a.cc:19:32: error: expected primary-expression before '>' token
   19 |             queue<pair<int, int>> q;
      |                                ^~
a.cc:19:35: error: 'q' was not declared in this scope
   19 |             queue<pair<int, int>> q;
      |                                   ^
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 = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  rep(i,h) cin >> f[i];
  rep(si,h)rep(sj,w) {
    if (f[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;
      rep(dir,4) {
        int ni = i + dx[dir], nj = j + dy[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: In function 'int main()':
a.cc:17:48: error: 'INF' was not declared in this scope
   17 |     vector<vector<int>> dist(h, vector<int>(w, INF));
      |                                                ^~~
a.cc:31:13: error: 's' was not declared in this scope
   31 |         if (s[ni][nj] == '#') continue;
      |             ^
a.cc:36:19: error: 'j' was not declared in this scope
   36 |       if (dist[i][j] == INF) continue;
      |                   ^
a.cc:37:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |       ans = max(ans,dist[i][j]);
      |       ^~~
      |       abs
a.cc:37:29: error: 'j' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |                             ^
a.cc:40:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |   cout << ans << endl;
      |           ^~~
      |           abs
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 = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  rep(i,h) cin >> f[i];
  rep(si,h)rep(sj,w) {
    if (f[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;
      rep(dir,4) {
        int ni = i + dx[dir], nj = j + dy[dir];
        if ()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: In function 'int main()':
a.cc:17:48: error: 'INF' was not declared in this scope
   17 |     vector<vector<int>> dist(h, vector<int>(w, INF));
      |                                                ^~~
a.cc:30:13: error: expected primary-expression before ')' token
   30 |         if ()if (ni<0||ni>=h||nj<0||nj>=w) continue;
      |             ^
a.cc:31:13: error: 's' was not declared in this scope
   31 |         if (s[ni][nj] == '#') continue;
      |             ^
a.cc:36:19: error: 'j' was not declared in this scope
   36 |       if (dist[i][j] == INF) continue;
      |                   ^
a.cc:37:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |       ans = max(ans,dist[i][j]);
      |       ^~~
      |       abs
a.cc:37:29: error: 'j' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |                             ^
a.cc:40:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w;
  cin >> h >> w;
  vs s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;          vector<vb> seen(h,vb(w));
  rep(i,h) {
    rep(j,w) {
      rep(k,h) {
        rep(l,w) {
          if(s[i][j] == '#' || s[k][l] == '#') continue;
          vii d(h,vi(w));
          queue<P> q;
rep(y,h)rep(x,w)seend[y][x]=0;
          q.emplace(i,j);
          d[i][j] = 0;
          while(sz(q)) {
            int y = q.front().fi;
            int x = q.front().se;
            q.pop();
            seen[y][x] = true;
            rep(dis,4) {
              int ny = dy[dis] + y;
              int nx = dx[dis] + x;
              if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
              if(s[ny][nx] == '#' || seen[ny][nx]) continue;
              d[ny][nx] = d[y][x] + 1;
              q.emplace(ny,nx);
            }
          }
          chmax(ans, d[k][l]);
        }
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:17: error: 'seend' was not declared in this scope; did you mean 'seen'?
   55 | rep(y,h)rep(x,w)seend[y][x]=0;
      |                 ^~~~~
      |                 seen
Language: C++

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

const int maxH=25,maxW=25;
int H,W;
char grid[maxH][maxW+1];

int dx[4]={-1,0,1,0}, dy[4]={0,-1,0,1};
bool used[maxH][maxW];
int dist[maxH][maxW][maxH][maxW];


void bfs(int x,int y, int dist[maxH][maxW]){
    queue<int> qx, qy;
    qx.push(x);qy.push(y);
    while(!qx.empty()){
        int x=qx.front();qx.pop();
        int y=qy.front();qy.pop();
        used[x][y]=true;
        for(int i=0;i<4;i++){
            int x2=x+dx[i],y2=y+dy[i];
            if(x2>=0 && x2<H && y2>=0 && y2<W && grid[x2][y2]=='.' && !used[x2][y2]){
                qx.push(x2);
                qy.push(y2);
                dist[x2][y2]=dist[x][y]+1;
            }
        }
    }
}

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

int main(){
    input();
    for(int x=0;x<H;x++){
        for(int y=0;y<W;y++){
            if(grid[x][y]=='.'){
                memset(used,false,sizeof(used));
                bfs(x,y,dist[x][y]);
            }
        }
    }
    int res=0;
    for(int x1=0;x1<H;x1++){
        for(int y1=0;y1<W;y1++){
            for(int x2=0;x2<H;x2++){
                for(int y2=0;y2<W;y2++){
                    res = max(res, dist[x1][y1][x2][y2]);
                }
            }
        }
    }
    cout << res << endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: 'memset' was not declared in this scope
   48 |                 memset(used,false,sizeof(used));
      |                 ^~~~~~
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++

/*
ABC151-D AC in 10ms
幅優先探索 : 最短距離を求める
参考　: https://qiita.com/drken/items/6a95b57d2e374a3d3292#4-2-%E3%82%B0%E3%83%A9%E3%83%95%E4%B8%8A%E3%81%AE%E6%8E%A2%E7%B4%A2
*/

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Pii;

//4方向の移動を示す
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int bfs(int sx, int sy){
  //(sx, sy)からの最大距離を返す
  int ans;
  vector<vector<int>> dist(H, vector<int>(W, -1)); //dist=-1のマスは未発見
  queue<Pii> unvisited; //発見したけど訪問していないマスの情報
  /*
  pushは後ろから入れる
  popは先頭から出す
  */

  dist[sx][sy] = 0; //スタートを発見
  unvisited.push(Pii(sx, sy)); //訪問はしてないのでスタートを入れる

  //探索開始
  while(!unvisited.empty()){
    //unvisitedが空になるまで
    pair<int, int> current = unvisited.front(); //先頭を読む
    unvisited.pop(); //先頭を捨てる
    int x = current.first;
    int y = current.second;

    for(int i=0; i<4; i++){
      //4方向にnextを探索
      int next_x = x + dx[i];
      int next_y = y + dy[i];
      if(next_x<0 || next_x>=H || next_y<0 || next_y>=W) continue; //外に出たらダメ
      if(S[next_x][next_y]=='#') continue; //壁はダメ

      if(dist[next_x][next_y] == -1){
        //未発見だったらこれで発見なので未訪問キューに入れる
        unvisited.push(Pii(next_x, next_y));
        dist[next_x][next_y] = dist[x][y] + 1; //nextのdistは現在地+1
        ans = max(ans, dist[next_x][next_y]);
      }
    }
  }
  return ans;
}

int main(){
  int H, W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin>>S[i];
  }

  ans = 0;

  for(int sx=0; sx<H; sx++)for(int sy=0; sy<W; sy++){
    if(S[sx][sy]=='.'){
      //スタートにできるとき      
      ans = max(ans, bfs(sx, sy));
    }
  }

  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int bfs(int, int)':
a.cc:18:28: error: 'H' was not declared in this scope
   18 |   vector<vector<int>> dist(H, vector<int>(W, -1)); //dist=-1のマスは未発見
      |                            ^
a.cc:18:43: error: 'W' was not declared in this scope
   18 |   vector<vector<int>> dist(H, vector<int>(W, -1)); //dist=-1のマスは未発見
      |                                           ^
a.cc:41:10: error: 'S' was not declared in this scope
   41 |       if(S[next_x][next_y]=='#') continue; //壁はダメ
      |          ^
a.cc: In function 'int main()':
a.cc:62:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |   ans = 0;
      |   ^~~
      |   abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
vector<ll> dx = {1, 0, -1, 0};
vector<ll> dy = {0, 1, 0, -1};

int main() {
  IN(ll, H);
  IN(ll ,W);
  AIN(string, maze, H);
  ll ans = 0;
  vector<vector<ll>> d(H,vector<ll>(W,INF));
  queue<P> que;
  REP(i,H){
    REP(j, W){
      if(d.at(i).at(j) == INF)
        continue;
      vector<vector<ll>> d2= d
      que.push(P(i,j));
      d2.at(i).at(j) = 0;
      while(que.size()){
        P p = que.front();
        que.pop();
        REP(k,4){
          ll ny = p.first + dy.at(k);
          ll nx = p.second + dx.at(k);
          if(0 <= ny && ny < H && 0 <= nx && nx < W && maze.at(ny).at(nx) != '#' && d.at(ny).at(nx) == INF){
            que.push(P(ny,nx));
            d2.at(ny).at(nx) = d2.at(p.first).at(p.second) + 1;
            chmax(ans,d2.at(ny).at(nx));
          }
        }
      }
    }
  }
  OUT(ans);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:7: error: expected ',' or ';' before 'que'
   35 |       que.push(P(i,j));
      |       ^~~
Language: C++

#include "../header.hpp"
#include "graph.hpp"

signed main() {
    //%snippet.set('gridgraph')%

    // grid graphを通常のグラフに格納する。

    int h, w;
    cin >> h >> w;
    int n = h * w;
    vvi block(h, vi(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) { block[i][j] = (s[j] == '#' ? 1 : 0); }
    }

    Graph g(n);

    auto nid = [&](int i, int j){return (i*w + j);};  // node_id // (i, j) -> i*w + j
    auto pos = [&](int u){
        pii res;
        res = {u/w, u%w};
        return res;
    };

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

    // 下と右のみ. rep(k, 4)をrep(k, 2)に変更するのも忘れない。
    // int di[] = {1, 0};
    // int dj[] = {0, 1};
    rep(i, h) rep(j, w) {
        if (block[i][j]) continue;  // blockから出る辺はない
        rep(k, 4) {
            int ni = i + di[k];
            int nj = j + dj[k];
            if (is_in(ni, 0, h) && is_in(nj, 0, w)) {
                if (block[ni][nj]) continue;  // blockに入る辺はない
                g.add_edge(nid(i, j), nid(ni, nj));
                // 自分から生える辺だけでよい。そうしないと二重辺になってしまう。
            }
        }
    }

    int ans = 0;
    rep(s, n){
        auto d = g.dijkstra(s);
        rep(i, sz(d)) if (d[i]<INF) chmax(ans, d[i]);
    }
    cout << ans << endl;

    //%snippet.end()%
}


Compiler output:
a.cc:1:10: fatal error: ../header.hpp: No such file or directory
    1 | #include "../header.hpp"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h,w;
    int ans = 0;
    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];
                int nj = j + dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) 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;
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: cannot convert 'std::queue<std::pair<int, int> >::empty' from type 'bool (std::queue<std::pair<int, int> >::)() const' to type 'bool'
   35 |         while(!q.empty){
      |                  ^~~~~
a.cc:35:18: error: in argument to unary !
   35 |         while(!q.empty){
      |                ~~^~~~~
Language: C++

x, bgn.y);
            vector<vector<char>> tmaze = maze;
            int mxlen                  = 0;
            point now                  = {0, 0, 0};
            // while (que.size() > loadcnt) {
            while (!que.empty()) {
                now = que.front();
                que.pop();
                // printf("  now: %d, %d\n", now.x, now.y);
                rep(i, 0, 4) {
                    point next = {now.x + mx[i], now.y + my[i], now.dp + 1};
                    if (next.x >= 0 && next.x < w && next.y >= 0 && next.y < h) {
                        // if (maze[next.x][next.y] == '.') {
                        if (tmaze[next.x][next.y] == '.') {
                            // printf("    push: %d, %d\n", next.x, next.y);
                            tmaze[next.x][next.y] = 'x';
                            que.push(next);
                        }
                    }
                }

                mxlen = max(mxlen, now.dp);
            }
            mxmxlen = max(mxmxlen, mxlen);
        }
    }

    cout << mxmxlen << endl;

    return 0;
}


Compiler output:
a.cc:1:1: error: 'x' does not name a type
    1 | x, bgn.y);
      | ^
a.cc:2:13: error: 'vector' does not name a type
    2 |             vector<vector<char>> tmaze = maze;
      |             ^~~~~~
a.cc:4:13: error: 'point' does not name a type; did you mean 'int'?
    4 |             point now                  = {0, 0, 0};
      |             ^~~~~
      |             int
a.cc:6:13: error: expected unqualified-id before 'while'
    6 |             while (!que.empty()) {
      |             ^~~~~
a.cc:24:13: error: 'mxmxlen' does not name a type
   24 |             mxmxlen = max(mxmxlen, mxlen);
      |             ^~~~~~~
a.cc:25:9: error: expected declaration before '}' token
   25 |         }
      |         ^
a.cc:26:5: error: expected declaration before '}' token
   26 |     }
      |     ^
a.cc:28:5: error: 'cout' does not name a type
   28 |     cout << mxmxlen << endl;
      |     ^~~~
a.cc:30:5: error: expected unqualified-id before 'return'
   30 |     return 0;
      |     ^~~~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

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

int main(){
  int H,W; cin>>H>>W;
  vector<vector<char>>a(H,vector<char>(W));
  rep(i,H){
      rep(j,W)cin>>a[i][j];
  }
  int mx=0;
  int ans=0;
  rep(i,H){
      rep(j,W){
          mx=0;
          vector<vector<int>>dist(H,vector<int>(W,-1));
          dist[i][j]=0;
          queue<pair<int,int>>q;
          q.push(make_pair(i,j));
          while(!q.empty()){
              ll y=q.front().first,x=q.front().second;
              q.pop();
              rep(k,4){
                  ll ny=y+dy[k],nx=x+dx[k];
                  if(ny<0||nx<0||ny>=H||nx>=W)continue;
                  if(a[ny][nx]=='#')continue;
                  if(dist[ny][nx]!=-1)continue;
                  q.push(make_pair(ny,nx));
                  dist[ny][nx]=dist[y][x]+1;
                  mx=max(dist[ny][nx],mx);
              }
          }
      }
      ans=max(max,mx);

  }
  cout<<ans<<endl;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:41:14: error: no matching function for call to 'max(<unresolved overloaded function type>, int&)'
   41 |       ans=max(max,mx);
      |           ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:41:14: note:   couldn't deduce template parameter '_Tp'
   41 |       ans=max(max,mx);
      |           ~~~^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H,W;
char S[20][20];
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
struct ichi {
    int y;
    int x;
    int depth;
};

queue<ichi> q;
int res = 0;
int bfs(int s, int t, int h) {
    int hantei[20][20] = {};
    struct ichi start;
        start.x = t;
        start.y = s;
        start.depth = h;
        
       
    q.push(start);
        while(!q.empty()) {
            ichi now = q.front(); q.pop();
            hanntei[now.x][now.y] = 1;
         res = max(res, now.depth);
            
        for(int i = 0; i < 4; i++) {
            ichi next = { now.y + dy[i], now.x + dx[i], now.depth + 1};
        
        if(next.x < 0 || next.x >= H || next.y < 0 || next.y >= W) continue;
        if(S[next.y][next.x] == '#') continue;
        if(hantei[next.x][next.y] == 1) continue;
        if(next.y >= 0 && next.y < H && next.x >= 0 && next.x < W && S[next.y][next.y] == '.') {
            q.push(next);
            
        }
        }
        }

        return res;
}
int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for(int a = 0; a < H; a++) {
        for(int b = 0; b < W; b++) {
           if(S[a][b] == '#') continue;

           ans = max(ans, bfs(a, b, 0));
        }
    }

    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int)':
a.cc:27:13: error: 'hanntei' was not declared in this scope; did you mean 'hantei'?
   27 |             hanntei[now.x][now.y] = 1;
      |             ^~~~~~~
      |             hantei
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H,W;
char S[20][20];
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
struct ichi {
    int y;
    int x;
    int depth;
};

queue<ichi> q;
int res = 0;
int bfs(int s, int t, int h) {
    struct ichi start;
        start.x = t;
        start.y = s;
        start.depth = h;
        
       
    q.push(start);
        while(!q.empty()) {
            ichi now = q.front(); q.pop();
         res = max(res, now.depth());
            
        for(int i = 0; i < 4; i++) {
            ichi next = { now.y + dy[i], now.x + dx[i], now.depth + 1};
        
        if(next.x < 0 || next.x >= H || next.y < 0 || next.y >= W) continue;
        if(S[next.y][next.x] == '#') continue;
        if(next.y >= 0 && next.y < H && next.x >= 0 && next.x < W && S[next.y][next.y] == '.') {
            q.push(next);
        }
        }
        }

        return res;
}
int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for(int a = 0; a < H; a++) {
        for(int b = 0; b < W; b++) {
           if(S[a][b] == '#') continue;

           ans = max(ans, bfs(a, b, 0));
        }
    }

    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int)':
a.cc:26:34: error: expression cannot be used as a function
   26 |          res = max(res, now.depth());
      |                         ~~~~~~~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H,W;
char S[20][20];
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
struct ichi {
    int y;
    int x;
    int depth;
};

queue<ichi> q;
int res = 0;
int bfs(int s, int t, int h) {
    struct ichi start;
        start.x = t;
        start.y = s;
        start.depth = h;
        
        res = max(res, now.depth());
    q.push(start);
        while(!q.empty()) {
            ichi now = q.front(); q.pop();

            
        for(int i = 0; i < 4; i++) {
            ichi next = { now.y + dy[i], now.x + dx[i], now.depth + 1};
        
        if(nx < 0 || next.x >= H || next.y < 0 || next.y >= W) continue;
        if(S[next.y][next.x] == '#') continue;
        if(next.y >= 0 && next.y < H && next.x >= 0 && next.x < W && S[next.y][next.y] == '.') {
            q.push(next);
        }
        }
        }

        return res;
}
int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for(int a = 0; a < H; a++) {
        for(int b = 0; b < W; b++) {
           if(S[a][b] == '#') continue;

           ans = max(ans, bfs(a, b, 0));
        }
    }

    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int)':
a.cc:22:24: error: 'now' was not declared in this scope; did you mean 'pow'?
   22 |         res = max(res, now.depth());
      |                        ^~~
      |                        pow
a.cc:31:12: error: 'nx' was not declared in this scope; did you mean 'dx'?
   31 |         if(nx < 0 || next.x >= H || next.y < 0 || next.y >= W) continue;
      |            ^~
      |            dx