Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
 
// C++ Libraries
#include <map>
 
#define NUM 200010
 
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
 
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
 
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
 
 
 
 
 

 
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];

 
unsigned int hash_length=0;
 
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
    return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
 
 
 
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
    x = root(x, par, rank);
    y = root(y, par, rank);
    if (x == y) return;
    
    if(rank[x] < rank[y]) {
        par[x] = y;
        count[y] = count[x] + count[y] + 1;
    } else {
        par[y] = x;
        count[x] = count[y] + count[x] + 1;
        if (rank[x] == rank[y]) rank[x]++;
    }
}
 
 
 
int main(){
    unsigned int i, j, h;
    unsigned int terminal_road, terminal_rail;
    int flag;
    scanf("%d%d%d", &n, &k, &l);
    
    
    for(i=0; i<NUM; i++) {
        par_road[i] = i;
        rank_road[i] = 0;
        count_road[i] = 0;
        par_rail[i] = i;
        rank_rail[i] = 0;
        count_rail[i] = 0;
        count[i].value=0;
        count[i].count=0;
        
        // for(j=1; j<n; j++) {
        //     count[i][j] = 0;
        // }
    }
    
    for(i=1; i<=k; i++) {
        scanf("%d%d", &road[i][0], &road[i][1]);
        int c1 = road[i][0];
        int c2 = road[i][1];
        unite(c1, c2, par_road, rank_road, count_road);
    }
    for(i=1; i<=l; i++) {
        scanf("%d%d", &rail[i][0], &rail[i][1]);
        int c1 = rail[i][0];
        int c2 = rail[i][1];
        unite(c1, c2, par_rail, rank_rail, count_rail);
    }
    
    u_int64 int hash;
    // std::map<unsigned long long int, unsigned int> mp;
    std::map<std::string, u_int64> mp;
    std::string hash_str;
    
    for(i=1; i<=n; i++) {
        hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
        // hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
        
        auto itr = mp.find(hash);        // "xyz" が設定されているか？
        if( itr != mp.end() ) {
            mp[hash]++;
        } else {
            mp[hash] = 1;
        }

        
    }
    
    for(i=1; i<=n; i++) {
        hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);

        printf("%d ", mp[hash]);
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:9: error: 'count' was not declared in this scope
   80 |         count[i].value=0;
      |         ^~~~~
a.cc:101:5: error: 'u_int64' was not declared in this scope; did you mean 'u_int64_t'?
  101 |     u_int64 int hash;
      |     ^~~~~~~
      |     u_int64_t
a.cc:103:34: error: template argument 4 is invalid
  103 |     std::map<std::string, u_int64> mp;
      |                                  ^
a.cc:107:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
  107 |         hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
      |         ^~~~
      |         std::hash
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from a.cc:5:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
   59 |     struct hash;
      |            ^~~~
a.cc:110:23: error: request for member 'find' in 'mp', which is of non-class type 'int'
  110 |         auto itr = mp.find(hash);        // "xyz" が設定されているか？
      |                       ^~~~
a.cc:111:23: error: request for member 'end' in 'mp', which is of non-class type 'int'
  111 |         if( itr != mp.end() ) {
      |                       ^~~
a.cc:121:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
  121 |         hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
      |         ^~~~
      |         std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
   59 |     struct hash;
      |            ^~~~