Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>

const int MOD = 1000000007, int INF=1111111111;
using namespace std;
typedef long long ll;

template<class T = ll>
struct Edge {
  int to;
  T cost;
  Edge() {}
  Edge(int to, T cost) : to(to), cost(cost) {}
  bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

  int V = (int)edges.size();
  const int INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);
  dist[st] = 0;

  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
  p_que.emplace(dist[st], st);

  while (!p_que.empty()) {

    Edge<T> now(p_que.top().to, p_que.top().cost);
    p_que.pop();

    if(dist[now.to] < now.cost) continue;

    for(const Edge<T> &e : edges[now.to]) {
      T tmp_cost = now.cost + e.cost;
      if (dist[e.to] > tmp_cost) {
        dist[e.to] = tmp_cost;
        p_que.emplace(e.to, dist[e.to]);
      }
    }
  }

  return dist;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin>>N;
  int u,v,len;
  vector<vector<Edge<int> > > edges(N);

  for (int i=0;i<N-1;i++) {
    cin>>u>>v>>len;
    u--;v--;
    edges[u].emplace_back(make_pair(v,len));
    edges[v].emplace_back(make_pair(u,len));
  }

  auto ans = Dijkstra<int>(edges, 0);

  for(auto& i: ans){
    if(i%2){
      cout<<1<<"\n";
    }else{
      cout<<0<<"\n";
    }
  }
}

Compiler output:
a.cc:13:29: error: expected unqualified-id before 'int'
   13 | const int MOD = 1000000007, int INF=1111111111;
      |                             ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Edge<int>; _Args = {std::pair<int, int>}; _Tp = Edge<int>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Edge<int>; _Args = {std::pair<int, int>}; _Tp = Edge<int>; allocator_type = std::allocator<Edge<int> >]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::pair<int, int>}; _Tp = Edge<int>; _Alloc = std::allocator<Edge<int> >; reference = Edge<int>&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:68:26:   required from here
   68 |     edges[u].emplace_back(make_pair(v,len));
      |     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'Edge<int>::Edge(std::pair<int, int>)'
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:3: note: candidate: 'Edge<T>::Edge(int, T) [with T = int]'
   22 |   Edge(int to, T cost) : to(to), cost(cost) {}
      |   ^~~~
a.cc:22:3: note:   candidate expects 2 arguments, 1 provided
a.cc:21:3: note: candidate: 'Edge<T>::Edge() [with T = int]'
   21 |   Edge() {}
      |   ^~~~
a.cc:21:3: note:   candidate expects 0 arguments, 1 provided
a.cc:18:8: note: candidate: 'constexpr Edge<int>::Edge(const Edge<int>&)'
   18 | struct Edge {
      |        ^~~~
a.cc:18:8: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const Edge<int>&'
a.cc:18:8: note: candidate: 'constexpr Edge<int>::Edge(Edge<int>&&)'
a.cc:18:8: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'Edge<int>&&'