Language: C++

#include<iostream>
#include<vector>

using namespace std;

int dfs(vector<vector<int>> & g, vector<bool> & b, int idx)
{
  	b[idx] = false;
	int cnt = 1;
	for (int i = 0, len = g[idx].size(); i < len; i++)
		if (b[g[i]]) cnt += dfs(g, b, g[i]);
	return cnt;
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> g;
  g.resize(n);
  
  for (int i = 0, j, k; i < m; i++)
  {
	cin >> j >> k;
	g[j-1].push_back(k-1);
	g[k-1].push_back(j-1);
  }
  
  vector<bool> b;
  b.resize(n);
  for (int i = 0; i < n; i++) b[i] = true; 

  int max = 0, cnt;
  for (int i = 0; i < n; i++)
	if (b[i])
	{
		cnt = dfs(g, b, i);
		max = max < cnt ? cnt : max;
	}

  cout << max;
  
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(std::vector<std::vector<int> >&, std::vector<bool>&, int)':
a.cc:11:22: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   11 |                 if (b[g[i]]) cnt += dfs(g, b, g[i]);
      |                      ^
In file included from /usr/include/c++/14/vector:67,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_bvector.h:1086:7: note: candidate: 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>; reference = std::vector<bool>::reference; size_type = long unsigned int]'
 1086 |       operator[](size_type __n)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:1086:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
 1086 |       operator[](size_type __n)
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_bvector.h:1091:7: note: candidate: 'std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](size_type) const [with _Alloc = std::allocator<bool>; const_reference = bool; size_type = long unsigned int]'
 1091 |       operator[](size_type __n) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:1091:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<bool>::size_type' {aka 'long unsigned int'}
 1091 |       operator[](size_type __n) const
      |                  ~~~~~~~~~~^~~
a.cc:11:40: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'int'
   11 |                 if (b[g[i]]) cnt += dfs(g, b, g[i]);
      |                                     ~~~^~~~~~~~~~~~
      |                                        |
      |                                        __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type {aka std::vector<int>}
a.cc:6:56: note:   initializing argument 3 of 'int dfs(std::vector<std::vector<int> >&, std::vector<bool>&, int)'
    6 | int dfs(vector<vector<int>> & g, vector<bool> & b, int idx)
      |                                                    ~~~~^~~