Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <queue>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<vector<pair<int,int>>> t = vector<vector<pair<int,int>>>(n+1, vector<pair<int,int>>(0));
  vector<bool> flag = vector<bool>(n+1, false);
  //black == true;
  vector<bool> color = vector<bool>(n+1, false);
  queue<int> q;
  int tmpu, tmpv
  ll tmpw;
  REP(i, n - 1)
  {
    cin >> tmpu >> tmpv >> tmpw;
    t[tmpu - 1].push_back({tmpv - 1,tmpw%2});
    t[tmpv - 1].push_back({tmpu - 1,tmpw%2});
  }
  color[0] = true;

  q.push(0);

  while (!q.empty())
  {
    for (auto kv : t[q.front()])
    {
      int node = kv.first;
      int w = kv.second;
      if (flag[node])
        continue;
      if (w == 0)
      {
        color[node] = color[q.front()];
      }
      else
      {
        color[node] = !color[q.front()];
      }
      q.push(node);
    }
    flag[q.front()] = true;
    q.pop();
  }
  REP(i, n)
  {
    if (color[i])
    {
      cout << '1' << endl;
    }
    else
    {
      cout << '0' << endl;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:28:3: error: expected initializer before 'll'
   28 |   ll tmpw;
      |   ^~
a.cc:31:20: error: 'tmpv' was not declared in this scope; did you mean 'tmpu'?
   31 |     cin >> tmpu >> tmpv >> tmpw;
      |                    ^~~~
      |                    tmpu
a.cc:31:28: error: 'tmpw' was not declared in this scope; did you mean 'tmpu'?
   31 |     cin >> tmpu >> tmpv >> tmpw;
      |                            ^~~~
      |                            tmpu
a.cc:32:26: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   32 |     t[tmpu - 1].push_back({tmpv - 1,tmpw%2});
      |     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~