Language: C++

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
int cnave[200005][200005];
int a[200005],b[200005];
inline int finda(int t){
	if(a[t]==t) return a[t];
	int x=finda(a[t]);
	a[t]=x;
	return x;
}
inline int findb(int t){
	if(b[t]==t) return b[t];
	int x=findb(b[t]);
	b[t]=x;
	return x;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,p,q,i,j,x,y;
	cin>>n>>p>>q;
	for(i=0;i<n;i++) a[i]=b[i]=i;
	for(i=0;i<p;i++){
		cin>>x>>y;
		x--,y--;
		a[finda(x)]=finda(y);
	}
	for(i=0;i<q;i++){
		cin>>x>>y;
		x--,y--;
		b[findb(x)]=findb(y);
	}
	for(i=0;i<n;i++){
		finda(i);
		findb(i);
		cnave[a[i]][b[i]]++;
	}
	for(i=0;i<n;i++) cout<<cnave[a[i]][b[i]]<<" ";
	cout<<endl;
	return 0;
}


Compiler output:
/tmp/ccGtka3L.o: in function `main':
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x114): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x279): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x2ef): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o
/tmp/ccGtka3L.o: in function `finda(int)':
a.cc:(.text._Z5findai[_Z5findai]+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o
a.cc:(.text._Z5findai[_Z5findai]+0x37): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status