Language: C++

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


  
  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(){
  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;
  }

  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:12:8: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   12 |     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:20:12: error: expected unqualified-id before '[' token
   20 |     if(rank[x]<rank[y]) par[x]=y;
      |            ^
a.cc:20:25: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   20 |     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:22:7: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   22 |       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:23:14: error: expected unqualified-id before '[' token
   23 |       if(rank[x]==rank[y]) rank[x]++;
      |              ^
a.cc:23:35: error: expected initializer before '++' token
   23 |       if(rank[x]==rank[y]) rank[x]++;
      |                                   ^~
a.cc:23:35: error: expected ';' before '++' token
a.cc: In function 'bool same(int, int)':
a.cc:27:27: error: named return values are no longer supported
   27 |   bool same(int x, int y) return find(x)==find(y);
      |                           ^~~~~~
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 | }
      | ^