Language: C++

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


void dfs(vector<long>* edge,bool visited[],int n,long start){
	visited[start] = true;

	for(int i=0;i<edge[start].size();i++){
		long next = edge[start][i];
		if(!visited[next]){
			dfs(edge,visited,n,next);
		}
	}
}

int find(vector<int>* edge, int n){
	bool visited[n];
	memset(visited,0,sizeof(visited));
	long count = 0;
	for(int i=0;i<n;i++){
		if(!visited[i]){
			count++;
			dfs(edge,visited,n,i);
		}
	}
	return count;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<long>* edge = new vector<long>[n];
	for(int i=0;i<m;i++){
		long a,b;
		cin >> a>> b;
		edge[a-1].push_back(b-1);
		edge[b-1].push_back(a-1);
	}

	long res = find(edge,n);

	cout << res-1;


}

Compiler output:
a.cc: In function 'int find(std::vector<int>*, int)':
a.cc:23:29: error: cannot convert 'std::vector<int>*' to 'std::vector<long int>*'
   23 |                         dfs(edge,visited,n,i);
      |                             ^~~~
      |                             |
      |                             std::vector<int>*
a.cc:5:24: note:   initializing argument 1 of 'void dfs(std::vector<long int>*, bool*, int, long int)'
    5 | void dfs(vector<long>* edge,bool visited[],int n,long start){
      |          ~~~~~~~~~~~~~~^~~~
a.cc: In function 'int main()':
a.cc:40:24: error: no matching function for call to 'find(std::vector<long int>*&, int&)'
   40 |         long res = find(edge,n);
      |                    ~~~~^~~~~~~~
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:1:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 2 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 2 provided
a.cc:16:5: note: candidate: 'int find(std::vector<int>*, int)'
   16 | int find(vector<int>* edge, int n){
      |     ^~~~
a.cc:16:23: note:   no known conversion for argument 1 from 'std::vector<long int>*' to 'std::vector<int>*'
   16 | int find(vector<int>* edge, int n){
      |          ~~~~~~~~~~~~~^~~~