Language: C++

#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

int N;
vector<pii> G[100010];
signed int color[100010];

signed main()
{
  iostreamBooster();

  cin >> N;
  rep(i, 0, N-1) {
    int s, t, c;
    cin >> s >> t >> c;
    G[s].emplace_back(t, c & 1);
    G[t].emplace_back(s, c & 1);
  }

  // F:node, S:color
  queue<pii> que;
  auto paintNode = [&](int u, int ink) {
    que.emplace(u, ink);
    color[u] = ink;
  };

  memset(color, -1, sizeof(color));
  paintNode(1, 0);

  while(!que.empty()) {
    const auto nowNode = que.front().first;
    const auto nowColor = que.front().second;
    que.pop();

    for (const auto &e : G[nowNode]) {
      const int nxt = e.first;
      const bool odd = e.second;
      if (color[nxt] == -1) {
        paintNode(e.first, (odd) ? (1 - nowColor) : (nowColor));
      }
    }
  }


  rep(i, 1, N+1) {
    cout << color[i] << '\n';
  }

  return 0;
}

#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

int N;
vector<pii> G[100010];
signed int color[100010];

signed main()
{
  iostreamBooster();

  cin >> N;
  rep(i, 0, N-1) {
    int s, t, c;
    cin >> s >> t >> c;
    G[s].emplace_back(t, c & 1);
    G[t].emplace_back(s, c & 1);
  }

  // F:node, S:color
  queue<pii> que;
  auto paintNode = [&](int u, int ink) {
    que.emplace(u, ink);
    color[u] = ink;
  };

  memset(color, -1, sizeof(color));
  paintNode(1, 0);

  while(!que.empty()) {
    const auto nowNode = que.front().first;
    const auto nowColor = que.front().second;
    que.pop();

    for (const auto &e : G[nowNode]) {
      const int nxt = e.first;
      const bool odd = e.second;
      if (color[nxt] == -1) {
        paintNode(e.first, (odd) ? (1 - nowColor) : (nowColor));
      }
    }
  }


  rep(i, 1, N+1) {
    cout << color[i] << '\n';
  }

  return 0;
}



Compiler output:
a.cc:69:39: error: redefinition of 'template<class A, class B> bool chmax(A&, const B&)'
   69 | template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
      |                                       ^~~~~
a.cc:8:39: note: 'template<class A, class B> bool chmax(A&, const B&)' previously declared here
    8 | template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
      |                                       ^~~~~
a.cc:70:39: error: redefinition of 'template<class A, class B> bool chmin(A&, const B&)'
   70 | template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
      |                                       ^~~~~
a.cc:9:39: note: 'template<class A, class B> bool chmin(A&, const B&)' previously declared here
    9 | template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
      |                                       ^~~~~
a.cc:71:15: error: redefinition of 'constexpr const int INF'
   71 | constexpr int INF  = 0x3f3f3f3f;
      |               ^~~
a.cc:10:15: note: 'constexpr const int INF' previously defined here
   10 | constexpr int INF  = 0x3f3f3f3f;
      |               ^~~
a.cc:72:15: error: redefinition of 'constexpr const i64 LINF'
   72 | constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
      |               ^~~~
a.cc:11:15: note: 'constexpr const i64 LINF' previously defined here
   11 | constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
      |               ^~~~
a.cc:73:15: error: redefinition of 'constexpr const int MOD'
   73 | constexpr int MOD  = int(1e9) + 7;
      |               ^~~
a.cc:12:15: note: 'constexpr const int MOD' previously defined here
   12 | constexpr int MOD  = int(1e9) + 7;
      |               ^~~
a.cc:75:5: error: redefinition of 'int N'
   75 | int N;
      |     ^
a.cc:14:5: note: 'int N' previously declared here
   14 | int N;
      |     ^
a.cc:76:13: error: redefinition of 'std::vector<std::pair<int, int> > G [100010]'
   76 | vector<pii> G[100010];
      |             ^
a.cc:15:13: note: 'std::vector<std::pair<int, int> > G [100010]' previously declared here
   15 | vector<pii> G[100010];
      |             ^
a.cc:77:12: error: redefinition of 'int color [100010]'
   77 | signed int color[100010];
      |            ^~~~~
a.cc:16:12: note: 'int color [100010]' previously declared here
   16 | signed int color[100010];
      |            ^~~~~
a.cc:79:8: error: redefinition of 'int main()'
   79 | signed main()
      |        ^~~~
a.cc:18:8: note: 'int main()' previously defined here
   18 | signed main()
      |        ^~~~