Language: C++

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int n, m;
const int N = 2e5 + 5;
int link[N], size[N];

int find(int u) {
    if(link[u] == u)return u;
    return link[u] = find(link[u]);
}

void unite(int u, int v) {
    int a = find(u);
    int b = find(v);
    if(size[a] < size[b])swap(a, b);
    size[a] += size[b];
    size[b] = 0;
    link[b] = a;
}

int32_t main() {

    fast
    cin >> n >> m;

    for(int i = 0; i < n; i++) {
        link[i] = i;
        size[i] = 1;
    }
    int a, b;
    while(m--) {
        cin >> a >> b;
        if(find(a - 1) != find(b - 1))
            unite(a - 1, b - 1);
    }
    int maxi = 0;
    // for(int i = 0; i < n; i++) {
    //     cout << size[i] << " ";
    // }
    // cout << endl;
    for(int i = 0; i < n; i++) {
        maxi = max(maxi, size[find(i)]);
    }
    cout << maxi;


    return 0;
}



Compiler output:
a.cc:9:11: error: 'long long int link [200005]' redeclared as different kind of entity
    9 | int link[N], size[N];
      |           ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'long long int find(long long int)':
a.cc:12:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   12 |     if(link[u] == u)return u;
      |              ^
a.cc:12:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |     if(link[u] == u)return u;
      |        ~~~~~~~~^~~~
a.cc:13:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |     return link[u] = find(link[u]);
      |                  ^
a.cc:13:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |     return link[u] = find(link[u]);
      |                                 ^
a.cc:13:26: error: no matching function for call to 'find(int (&)(const char*, const char*) noexcept)'
   13 |     return link[u] = find(link[u]);
      |                      ~~~~^~~~~~~~~
a.cc:11:5: note: candidate: 'long long int find(long long int)' (near match)
   11 | int find(int u) {
      |     ^~~~
a.cc:11:5: note:   conversion of argument 1 would be ill-formed:
a.cc:13:33: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'long long int' [-fpermissive]
   13 |     return link[u] = find(link[u]);
      |                           ~~~~~~^
      |                                 |
      |                                 int (*)(const char*, const char*) noexcept
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 1 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/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, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_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: In function 'void unite(long long int, long long int)':
a.cc:19:8: error: reference to 'size' is ambiguous
   19 |     if(size[a] < size[b])swap(a, b);
      |        ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:19:18: error: reference to 'size' is ambiguous
   19 |     if(size[a] < size[b])swap(a, b);
      |                  ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:20:5: error: reference to 'size' is ambiguous
   20 |     size[a] += size[b];
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:20:16: error: reference to 'size' is ambiguous
   20 |     size[a] += size[b];
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:21:5: error: reference to 'size' is ambiguous
   21 |     size[b] = 0;
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:22:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |     link[b] = a;
      |           ^
a.cc:22:13: error: assignment of read-only location '*(link + ((sizetype)b))'
   22 |     link[b] = a;
      |     ~~~~~~~~^~~
a.cc: In function 'int32_t main()':
a.cc:31:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |         link[i] = i;
      |               ^
a.cc:31:17: error: assignment of read-only location '*(link + ((sizetype)i))'
   31 |         link[i] = i;
      |         ~~~~~~~~^~~
a.cc:32:9: error: reference to 'size' is ambiguous
   32 |         size[i] = 1;
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~
a.cc:46:26: error: reference to 'size' is ambiguous
   46 |         maxi = max(maxi, size[find(i)]);
      |                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:14: note:                 'long long int size [200005]'
    9 | int link[N], size[N];
      |              ^~~~