Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
char a[30][30]= {0};
int q[]= {1,-1,0,0};
int w[]= {0,0,-1,1};
long long int l;
long long int h;
long long int max1=0;
struct node
{
    int x;
    int y;
};
int main()
{
    cin>>h;
    cin>>l;
    for(int i=1; i<=h; i++)
    {
        for(int j=1;j<=l;j++)
            cin>>a[i][j];
    }
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=l; j++)
        {
            if(a[i][j]=='#')
                continue;
            int vis[30][30]= {0};
            int sum1[30][30]= {0};
            queue<node>p;
            node r;
            r.x=i;
            r.y=j;
            p.push(r);
            while(!p.empty())
            {
                node t=p.front();
                p.pop();
                for(int h1=0; h1<4; h1++)
                {
                    int z=t.x+q[h1];
                    int x=t.y+w[h1];
                    if(vis[z][x])
                        continue;
                    if(z<=h&&z>0&&x<=l&&x>0&&a[z][x]=='.')
                    {
                        sum1[z][x]=sum1[t.x][t.y]+1;
                        node u;
                        u.x=z;
                        u.y=x;
                        vis[z][x]=1;
                        p.push(u);
                    }
                }
            }
            for(int i2=1;i2<=h;i2++)
            {
                for(int j2=1;j2<=l;j2++)
                {
                    if(vis[i2][j2])
                    {
                        max1=max(max1,sum1[i2][j2]);
                    }
                }
            }
        }
    }
    cout<<max1<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:33: error: no matching function for call to 'max(long long int&, int&)'
   64 |                         max1=max(max1,sum1[i2][j2]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:64:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   64 |                         max1=max(max1,sum1[i2][j2]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~
/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,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/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:64:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   64 |                         max1=max(max1,sum1[i2][j2]);
      |                              ~~~^~~~~~~~~~~~~~~~~~~