Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18

using Graph = vector<vector<int>>;
using Edge = pair<int,int>;
Graph G;

int N;
vector<int> ans;

void dfs(int x,int p,int t){
    ans[x] = t;
    for(auto next : G[x]){
        if(next.first == p) continue;
        if(next.second % 2 == 0){
            dfs(next,x,t);
        }else{
            dfs(next,x,1-t);
        }
    }
}


int main(){
    cin >> N;
    G = vector<vector<Edge>>(N);
  	ans = vector<int>(N);
    rep(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v,w)); 
        G[v].push_back(Edge(u,w)); 
    }
    dfs(0,-1,0);
    rep(i,N){
        cout << ans[i] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:29:17: error: request for member 'first' in 'next', which is of non-class type 'int'
   29 |         if(next.first == p) continue;
      |                 ^~~~~
a.cc:30:17: error: request for member 'second' in 'next', which is of non-class type 'int'
   30 |         if(next.second % 2 == 0){
      |                 ^~~~~~
a.cc: In function 'int main()':
a.cc:41:31: error: no match for 'operator=' (operand types are 'Graph' {aka 'std::vector<std::vector<int> >'} and 'std::vector<std::vector<std::pair<int, int> > >')
   41 |     G = vector<vector<Edge>>(N);
      |                               ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, int> > >' to 'const std::vector<std::vector<int> >&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, int> > >' to 'std::vector<std::vector<int> >&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, int> > >' to 'std::initializer_list<std::vector<int> >'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:47:23: error: no matching function for call to 'std::vector<int>::push_back(Edge)'
   47 |         G[u].push_back(Edge(v,w));
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = 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 'Edge' {aka 'std::pair<int, int>'} to 'const std::vector<int>::value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; value_type = 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 'Edge' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:48:23: error: no matching function for call to 'std::vector<int>::push_back(Edge)'
   48 |         G[v].push_back(Edge(u,w));
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = 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 'Edge' {aka 'std::pair<int, int>'} to 'const std::vector<int>::value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; value_type = 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 'Edge' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~