Language: C++

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

using namespace std;

vector<vector<int> > G;

vector<bool> used;

vector<int> rings;

char rec(char pos)
{
    used[pos] = true; char ret = 1;
    
    for(char i = 0; i < rings[pos]; i++)
    {
        if(!used[G[pos][i]])
        {
            ret = max(ret, rec(G[pos][i]) + 1);
        }
    }
    
    used[pos] = false;
    
    return ret;
}

int main()
{
    int N, A, B;
    
    while(true)
    {
        scanf("%d", &N);
        
        if(N == 0) { break; }

        G = vector<vector<int> >(100, vector<int>());
        
        used = vector<bool>(100);
        
        rings = vector<int>(100);
    
        for(int i = 0; i < N; i++)
        {
            scanf("%d", &A); A--;
            scanf("%d", &B); B--;
        
            G[A].push_back(B);
            G[B].push_back(A);
        }
        
        for(int i = 0; i < 100; i++)
        {
            rings[i] = G[i].size();
        }
        
        int nodes = 0;
        
        for(int i = 0; i < 100; i++)
        {
            if(rings[i])
            {
                nodes++;
            }
        }
    
        int ret = 0;
    
        for(int i = 0; i < 100; i++)
        {
            ret = max(ret, rec(i));
                
            if(ret == nodes) { break; }
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'char rec(char)':
a.cc:21:22: error: no matching function for call to 'max(char&, int)'
   21 |             ret = max(ret, rec(G[pos][i]) + 1);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 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:21:22: note:   deduced conflicting types for parameter 'const _Tp' ('char' and 'int')
   21 |             ret = max(ret, rec(G[pos][i]) + 1);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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 a.cc:3:
/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:21:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'char'
   21 |             ret = max(ret, rec(G[pos][i]) + 1);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:74:22: error: no matching function for call to 'max(int&, char)'
   74 |             ret = max(ret, rec(i));
      |                   ~~~^~~~~~~~~~~~~
/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:74:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'char')
   74 |             ret = max(ret, rec(i));
      |                   ~~~^~~~~~~~~~~~~
/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
/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:74:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |             ret = max(ret, rec(i));
      |                   ~~~^~~~~~~~~~~~~