Language: C++

#include<iostream>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int main(){
  int N;
  cin>>N;
  
  int par[N+1];
  int rank[N+1];
  
  for(int i=0; i<=N; ++i){
    par[i]=i;
    rank[i]=0;
  }
}
  
  
  int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
  }
  
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(rank[x]<rank[y]) par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  
  bool same(int x, int y) return find(x)==find(y);
  
int main(){
  for(int i=1; i<N; ++i){
    int A,B,C;
    cin>>A>>B>>C;
    if(C%2==0) unite(A,B);
  }
  
  for(int i=1; i<=N; ++i){
    if(same(i,1)==true) cout<<"1"<<endl;:
    else cout<<"0"<<endl;
  }
  
}


Compiler output:
a.cc: In function 'int find(int)':
a.cc:24:8: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   24 |     if(par[x]==x) return x;
      |        ^~~
      |        __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc: In function 'void unite(int, int)':
a.cc:32:12: error: expected unqualified-id before '[' token
   32 |     if(rank[x]<rank[y]) par[x]=y;
      |            ^
a.cc:32:25: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   32 |     if(rank[x]<rank[y]) par[x]=y;
      |                         ^~~
      |                         __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:34:7: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   34 |       par[y]=x;
      |       ^~~
      |       __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:35:14: error: expected unqualified-id before '[' token
   35 |       if(rank[x]==rank[y]) rank[x]++;
      |              ^
a.cc:35:35: error: expected initializer before '++' token
   35 |       if(rank[x]==rank[y]) rank[x]++;
      |                                   ^~
a.cc:35:35: error: expected ';' before '++' token
a.cc: In function 'bool same(int, int)':
a.cc:39:27: error: named return values are no longer supported
   39 |   bool same(int x, int y) return find(x)==find(y);
      |                           ^~~~~~
a.cc:42:18: error: 'N' was not declared in this scope
   42 |   for(int i=1; i<N; ++i){
      |                  ^
a.cc:48:19: error: 'N' was not declared in this scope
   48 |   for(int i=1; i<=N; ++i){
      |                   ^
a.cc:49:41: error: expected primary-expression before ':' token
   49 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |                                         ^
a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type]
   53 | }
      | ^