Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long
#define all(v) v.begin(),v.end()
using namespace std;
using Graph = vector<vector<int>>;
vector<bool> seen;
int dfs(const Graph &G, int v) {
   int key=0;
    seen[v] = true;
    for (auto next_v : G[v]) { 
       key++;
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
  return key;
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
  ll ans=0;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        ans=max(ans,dfs(G, v)); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: no matching function for call to 'max(long long int&, int)'
   52 |         ans=max(ans,dfs(G, v)); // v が未探索なら v を始点とした DFS を行う
      |             ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/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:52:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   52 |         ans=max(ans,dfs(G, v)); // v が未探索なら v を始点とした DFS を行う
      |             ~~~^~~~~~~~~~~~~~~
/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:52:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |         ans=max(ans,dfs(G, v)); // v が未探索なら v を始点とした DFS を行う
      |             ~~~^~~~~~~~~~~~~~~