Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

struct distance {
  int saki;
  int kyori;
  
  distance(int s, int k) {
    saki = s;
    kyori = k;
  }
};

using Graph = vector<vector<distance>>;
vector<int> color;

void coloring(const Graph &G, int v, int d) {
  if ((d % 2) == 0) color[v] = 1;
  else color[v] = 0;
  
  for (auto next_v : G[v]) {
    if (next_v.saki != -1) continue;
    
    int next_d = d + next_v.kyori;
    coloring(G, next_v.saki, next_d);
  }
}

int main() {
  int N; cin >> N;
  
  Graph G(N);
  
  for (i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(distance(b, c));
    G[b].push_back(distance(a, c));
  }
  
  color.assign(N + 1, -1);
  coloring(G, 1, 0);
  
  for (i = 1; i < N+1; i++) {
    cout << color[i] << endl;
  }
}

Compiler output:
a.cc:15:29: error: template argument 1 is invalid
   15 | using Graph = vector<vector<distance>>;
      |                             ^~~~~~~~
a.cc:15:29: error: template argument 2 is invalid
a.cc:15:37: error: template argument 1 is invalid
   15 | using Graph = vector<vector<distance>>;
      |                                     ^~
a.cc:15:37: error: template argument 2 is invalid
a.cc:18:21: error: 'Graph' does not name a type
   18 | void coloring(const Graph &G, int v, int d) {
      |                     ^~~~~
a.cc: In function 'void coloring(const int&, int, int)':
a.cc:22:23: error: invalid types 'const int[int]' for array subscript
   22 |   for (auto next_v : G[v]) {
      |                       ^
a.cc: In function 'int main()':
a.cc:33:3: error: 'Graph' was not declared in this scope; did you mean 'isgraph'?
   33 |   Graph G(N);
      |   ^~~~~
      |   isgraph
a.cc:35:8: error: 'i' was not declared in this scope
   35 |   for (i = 0; i < N - 1; i++) {
      |        ^
a.cc:38:5: error: 'G' was not declared in this scope
   38 |     G[a].push_back(distance(b, c));
      |     ^
a.cc:38:20: error: reference to 'distance' is ambiguous
   38 |     G[a].push_back(distance(b, c));
      |                    ^~~~~~~~
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_path.h:1431:1: note: candidates are: 'std::ptrdiff_t std::distance(filesystem::__cxx11::path::iterator, filesystem::__cxx11::path::iterator)'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:                 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
a.cc:5:8: note:                 'struct distance'
    5 | struct distance {
      |        ^~~~~~~~
a.cc:39:20: error: reference to 'distance' is ambiguous
   39 |     G[b].push_back(distance(a, c));
      |                    ^~~~~~~~
/usr/include/c++/14/bits/fs_path.h:1431:1: note: candidates are: 'std::ptrdiff_t std::distance(filesystem::__cxx11::path::iterator, filesystem::__cxx11::path::iterator)'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:                 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
a.cc:5:8: note:                 'struct distance'
    5 | struct distance {
      |        ^~~~~~~~
a.cc:43:12: error: 'G' was not declared in this scope
   43 |   coloring(G, 1, 0);
      |            ^
a.cc:45:8: error: 'i' was not declared in this scope
   45 |   for (i = 1; i < N+1; i++) {
      |        ^