Language: C++

#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N,K,L;
int a[200001],b[200001],rank_a[200001],rank_b[200001];
typedef pair<int ,int > P;
void init(int x){
  for(int i=0;i<x;i++){
    a[i]=i;b[i]=i;
    rank_a[i]=0;rank_b[i]=0;
  }
}

int find(int x,int *par){
  if(par[x]==x)return x;
  else return find(par[x],par);
}

void unite(int x,int y,int *par,int *rank){
  x=find(x,par);
  y=find(y,par);
  if(x==y)return ;
  if(rank[x]<rank[y])par[x]=y;
  else {
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

bool same(int x,int y,int *par){
  return find(x,par)==find(y,par);
}
int main(){
  cin >> N >> K >> L;
  init(N);
  for(int i=0;i<K;i++){
    int p,q;
    cin >> p >> q;
    p--;q--;
    unite(p,q,a,rank_a);
  }

  for(int i=0;i<L;i++){
    int r,s;
    cin >> r >> s;
    r--;s--;
    unite(r,s,b,rank_b);
  }
  map <P,int > m;
  for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
  for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:32: error: no matching function for call to 'find(int&)'
   51 |   for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
      |                            ~~~~^~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/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> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
   15 | int find(int x,int *par){
      |     ^~~~
a.cc:15:5: note:   candidate expects 2 arguments, 1 provided
a.cc:51:43: error: no matching function for call to 'find(int&)'
   51 |   for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
      |                                       ~~~~^~~~~~
/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> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
   15 | int find(int x,int *par){
      |     ^~~~
a.cc:15:5: note:   candidate expects 2 arguments, 1 provided
a.cc:52:40: error: no matching function for call to 'find(int&)'
   52 |   for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
      |                                    ~~~~^~~~~~
/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> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
   15 | int find(int x,int *par){
      |     ^~~~
a.cc:15:5: note:   candidate expects 2 arguments, 1 provided
a.cc:52:51: error: no matching function for call to 'find(int&)'
   52 |   for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
      |                                               ~~~~^~~~~~
/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> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
   15 | int find(int x,int *par){
      |     ^~~~
a.cc:15:5: note:   candidate expects 2 arguments, 1 provided