Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<vector<long long> > graph;
vector<long long> color;

void dfs(const vector<vector<long long> > &graph, long long node, int init =0 ){
    color[node] = init;
    for( long long next_node = 0; next_node < graph[node].size(); next_node++ ){
        if(color[next_node] != -1) continue;
        if(graph[node][next_node] != 0 && graph[node][next_node]%2 == 0){
            color[next_node] = init;
            dfs(graph, next_node, init);
        } 
        else if( graph[node][next_node] != 0 && graph[node][next_node]%2 == 1 ){
            color[next_node] = 1 - init;
            dfs(graph, next_node, 1 - init);
        }                      
    }
}


int main(){
    long long N; cin >> N;
    // init color as -1
    color.assign(N,-1);

    // input is always 3. init the values as -1
    graph.assign(N, vector<int>(N,0));
    for(int i=0; i<N-1; i++){
            long long u, v, w; cin >> u >> v >> w;
            graph[u-1][v-1] = w;
            graph[v-1][u-1] = w;

    }

    //first color to pupolate define as zero;
    for(long long v = 0; v < N; v++){
        if(color[v] != -1) continue;
        else dfs(graph, v);
    }

    for(auto c:color) cout << c << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: no matching function for call to 'std::vector<std::vector<long long int> >::assign(long long int&, std::vector<int>)'
   29 |     graph.assign(N, vector<int>(N,0));
      |     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  828 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:828:9: note:   template argument deduction/substitution failed:
a.cc:29:17: note:   deduced conflicting types for parameter '_InputIterator' ('long long int' and 'std::vector<int>')
   29 |     graph.assign(N, vector<int>(N,0));
      |     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; size_type = long unsigned int; value_type = std::vector<long long int>]'
  808 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<long long int> >::value_type&' {aka 'const std::vector<long long int>&'}
  808 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  855 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note:   candidate expects 1 argument, 2 provided