Language: C++

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

const int size=234567;
int N,K,L,I;
int p[size],q[size],r[size],s[size];
vector<int> road[size];
vector<int> rail[size];
vector<int> group[size];
vector<int> Group[size];
int g1[size],g2[size];
bool flag;

void dfsroad(int i,int j){
    g1[i]=j; 
    if(road[i].size()==0) return;
    for(int k=0; k<road[i].size(); k++){
        if(flag==0&&road[i][k]>i+1){
            I=i+1; flag=1;
        }
        dfsroad(road[i][k],j);
    }
    return;
}
void dfsrail(int i,int h){
    g2[i]=h;
    if(rail[i].size()==0) return;
    for(int k=0; k<rail[i].size(); k++){
        if(g1[i]==g1[rail[i][k]]) dfsrail(rail[i][k],h);
    }
    return;
}

int main(){

cin>>N>>K>>L;

for(int i=0; i<K; i++){
    scanf("%d %d",&p[i],&q[i]);
    road[p[i]].push_back(q[i]);
}
for(int i=0; i<L; i++){
    scanf("%d %d",&r[i],&s[i]);
    rail[r[i]].push_back(s[i]);
}
int J=1; I=1;
while(1){
    flag=0;
    if(I==N) break;
    if(g1[I]==0){
        dfsroad(I,J); J++;
    }
    I++
}
for(int i=1; i<=N; i++) group[g1[i]].push_back(i);

int H=1;
for(int i=1; i<J; i++){
    for(int k=0; k<group[i].size(); k++){
        if(g2[group[i][k]]==0){
            dfsrail(group[i][k],H); H++;
        }
    }
}

for(int i=1; i<=N; i++) Group[g2[i]].push_back(i);

for(int i=1; i<=N; i++) printf("%d ",Group[g2[i]].size());

return 0;
 
}

Compiler output:
a.cc:8:7: error: reference to 'size' is ambiguous
    8 | int p[size],q[size],r[size],s[size];
      |       ^~~~
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,
                 from a.cc: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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:8:15: error: reference to 'size' is ambiguous
    8 | int p[size],q[size],r[size],s[size];
      |               ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:8:23: error: reference to 'size' is ambiguous
    8 | int p[size],q[size],r[size],s[size];
      |                       ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:8:31: error: reference to 'size' is ambiguous
    8 | int p[size],q[size],r[size],s[size];
      |                               ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:9:18: error: reference to 'size' is ambiguous
    9 | vector<int> road[size];
      |                  ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:10:18: error: reference to 'size' is ambiguous
   10 | vector<int> rail[size];
      |                  ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:11:19: error: reference to 'size' is ambiguous
   11 | vector<int> group[size];
      |                   ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:12:19: error: reference to 'size' is ambiguous
   12 | vector<int> Group[size];
      |                   ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:13:8: error: reference to 'size' is ambiguous
   13 | int g1[size],g2[size];
      |        ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc:13:17: error: reference to 'size' is ambiguous
   13 | int g1[size],g2[size];
      |                 ^~~~
/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:6:11: note:                 'const int size'
    6 | const int size=234567;
      |           ^~~~
a.cc: In function 'void dfsroad(int, int)':
a.cc:17:5: error: 'g1' was not declared in this scope; did you mean 'y1'?
   17 |     g1[i]=j;
      |     ^~
      |     y1
a.cc:18:8: error: 'road' was not declared in this scope; did you mean 'read'?
   18 |     if(road[i].size()==0) return;
      |        ^~~~
      |        read
a.cc:19:20: error: 'road' was not declared in this scope; did you mean 'read'?
   19 |     for(int k=0; k<road[i].size(); k++){
      |                    ^~~~
      |                    read
a.cc: In function 'void dfsrail(int, int)':
a.cc:28:5: error: 'g2' was not declared in this scope
   28 |     g2[i]=h;
      |     ^~
a.cc:29:8: error: 'rail' was not declared in this scope
   29 |     if(rail[i].size()==0) return;
      |        ^~~~
a.cc:30:20: error: 'rail' was not declared in this scope
   30 |     for(int k=0; k<rail[i].size(); k++){
      |                    ^~~~
a.cc:31:12: error: 'g1' was not declared in this scope; did you mean 'y1'?
   31 |         if(g1[i]==g1[rail[i][k]]) dfsrail(rail[i][k],h);
      |            ^~
      |            y1
a.cc: In function 'int main()':
a.cc:41:20: error: 'p' was not declared in this scope
   41 |     scanf("%d %d",&p[i],&q[i]);
      |                    ^
a.cc:41:26: error: 'q' was not declared in this scope
   41 |     scanf("%d %d",&p[i],&q[i]);
      |                          ^
a.cc:42:5: error: 'road' was not declared in this scope; did you mean 'read'?
   42 |     road[p[i]].push_back(q[i]);
      |     ^~~~
      |     read
a.cc:45:20: error: 'r' was not declared in this scope
   45 |     scanf("%d %d",&r[i],&s[i]);
      |                    ^
a.cc:45:26: error: 's' was not declared in this scope
   45 |     scanf("%d %d",&r[i],&s[i]);
      |                          ^
a.cc:46:5: error: 'rail' was not declared in this scope
   46 |     rail[r[i]].push_back(s[i]);
      |     ^~~~
a.cc:52:8: error: 'g1' was not declared in this scope; did you mean 'y1'?
   52 |     if(g1[I]==0){
      |        ^~
      |        y1
a.cc:55:8: error: expected ';' before '}' token
   55 |     I++
      |        ^
      |        ;
   56 | }
      | ~       
a.cc:57:25: error: 'group' was not declared in this scope
   57 | for(int i=1; i<=N; i++) group[g1[i]].push_back(i);
      |                         ^~~~~
a.cc:57:31: error: 'g1' was not declared in this scope; did you mean 'y1'?
   57 | for(int i=1; i<=N; i++) group[g1[i]].push_back(i);
      |                               ^~
      |                               y1
a.cc:61:20: error: 'group' was not declared in this scope
   61 |     for(int k=0; k<group[i].size(); k++){
      |                    ^~~~~
a.cc:62:12: error: 'g2' was not declared in this scope
   62 |         if(g2[group[i][k]]==0){
      |            ^~
a.cc:68:25: error: 'Group' was not declared in this scope
   68 | for(int i=1; i<=N; i++) Group[g2[i]].push_back(i);
      |                         ^~~~~
a.cc:68:31: error