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;
        
        // 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);
    }
    
    uint64_t hash_num;
    // std::map<unsigned long long int, unsigned int> mp;
    std::map<std::string, uint64_t> mp;
    std::string hash_str;
    
    for(i=1; i<=n; i++) {
        hash_num = 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_num);        // "xyz" が設定されているか？
        if( itr != mp.end() ) {
            mp[hash]++;
        } else {
            mp[hash] = 1;
        }
 
        
    }
    
    for(i=1; i<=n; i++) {
        hash_num = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
 
        printf("%d ", mp[hash_num]);
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:27: error: no matching function for call to 'std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(uint64_t&)'
  108 |         auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
      |                    ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/map:63,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_map.h:1224:9: note: candidate: 'template<class _Kt> decltype (((std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
 1224 |         find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/14/bits/stl_map.h:1224:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]':
a.cc:108:27:   required from here
  108 |         auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
      |                    ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1224:57: error: no matching function for call to 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(const long unsigned int&)'
 1224 |         find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
      |                                          ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
 1291 |         _M_find_tr(const _Kt& __k)
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::__cxx11::basic_string<char> >; _SfinaeType = long unsigned int]':
/usr/include/c++/14/bits/stl_tree.h:1289:9:   required by substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]'
 1289 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:108:27:   required from here
  108 |         auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
      |                    ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::__cxx11::basic_string<char> >, long unsigned int, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]':
a.cc:108:27:   required from here
  108 |         auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
      |                    ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
 1300 |         _M_find_tr(const _Kt& __k) const
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h:1249:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) const [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
 1249 |         find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
      |         ^~~~
/usr/include/c++/14/bits/stl_map.h:1249:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) const [with _Kt = long unsigned int]':
a.cc:108:27:   required from here
  108 |         auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
      |                    ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1249:63: error: no matching function for call to 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(const long unsigned int&) const'
 1249 |         find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
      |                                                ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
 1291 |         _M_find_tr(const _Kt& __k)
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::_