Language: C++

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

template <typename T>
class DisjointSet {
   public:
    map<T, T> p;
    map<T, int> rank;
    DisjointSet() {
        p.clear();
        rank.clear();
    }
    DisjointSet(vector<T> elements) {
        p.clear();
        rank.clear();
        for (int i = 0; i < elements.size(); i++) {
            makeSet(elements[i]);
        }
    }
    void makeSet(T x) {
        p[x] = x;
        rank[x] = 0;
    }
    bool same(T x, T y) { return findSet(x) == findSet(y); }
    void unite(T x, T y) { link(findSet(x), findSet(y)); }

   private:
    void link(T x, T y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
    T findSet(T x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

#define MAX 100000
DisjointSet<int> T;
bool F[MAX + 1][MAX + 1];
bool B[MAX + 1][MAX + 1];
int N, M, K;

int main() {
    cin >> N >> M >> K;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            F[i][j] = false;
            B[i][j] = false;
        }
    }
    for (int i = 1; i <= N; i++) {
        T.makeSet(i);
    }
    for (int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        T.unite(a, b);
        F[a][b] = true;
        F[b][a] = true;
    }
    for (int i = 1; i <= K; i++) {
        int c, d;
        cin >> c >> d;
        B[c][d] = true;
        B[d][c] = true;
    }
    vector<int> ans(N + 1, 0);
    for (int u = 1; u <= N; u++) {
        for (int v = 1; v <= N; v++) {
            if (u == v) continue;
            if (B[u][v]) continue;
            if (F[u][v]) continue;
            if (T.same(u, v)) ans[u]++;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Compiler output:
/tmp/ccjiXgf8.o: in function `main':
a.cc:(.text+0xc): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x3d): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0xa8): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x1d7): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x1f9): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/ccjiXgf8.o
a.cc:(.text+0x209): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status