Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

ll flg[1145141];
//pair<ll , ll> edge;
vector<vector<pair<ll, ll > > > G[1145141];
vector<ll > ans;
vector<vector<ll > > weight;
//flg = 1 すでに到達済み 0＝まだ到達していない
void dfs(ll idx, ll from = -1){

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i];
        //同じだったらもう処理しない
        //頂点に戻ってきたら
        if(to == from){
            continue;
        }

        if(weight[idx][to] % 2 == 0){
            ans[to] = ans[idx];
        }else{
            ans[to] = (ans[idx] + 1) % 2;
        }

        dfs(to, idx);

    }
}

int main(){

    ll N;
    cin >> N;
    ans.resize(N);
    //初期化
    G.assign(N, vector<pair<ll, ll> >());
    //vector<vector<ll > > weight(N, vector<ll >(N, 0));
    weight.resize(N, vector<ll >(N));
    //グラフ入力
    for(ll i = 0; i < N-1; i++){
        ll u, v, w;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(v, w));
    }

    //伝搬実行
    dfs(0);
    for(ll i = 0; i < N; i++){
        cout << ans[i] << endl;;
    }

}

Compiler output:
a.cc: In function 'void dfs(ll, ll)':
a.cc:26:25: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<long long int, long long int> > >, std::vector<std::pair<long long int, long long int> > >::value_type' {aka 'std::vector<std::pair<long long int, long long int> >'} to 'll' {aka 'long long int'} in initialization
   26 |         ll to = G[idx][i];
      |                         ^
a.cc: In function 'int main()':
a.cc:50:7: error: request for member 'assign' in 'G', which is of non-class type 'std::vector<std::vector<std::pair<long long int, long long int> > > [1145141]'
   50 |     G.assign(N, vector<pair<ll, ll> >());
      |       ^~~~~~
a.cc:59:23: error: no matching function for call to 'std::vector<std::vector<std::pair<long long int, long long int> > >::push_back(std::pair<long long int, long long int>)'
   59 |         G[u].push_back(make_pair(v, w));
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
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::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; value_type = std::vector<std::pair<long long int, long long 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 'std::pair<long long int, long long int>' to 'const std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&' {aka 'const std::vector<std::pair<long long int, long long 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::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; value_type = std::vector<std::pair<long long int, long long 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 'std::pair<long long int, long long int>' to 'std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::vector<std::pair<long long int, long long int> >&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:60:23: error: no matching function for call to 'std::vector<std::vector<std::pair<long long int, long long int> > >::push_back(std::pair<long long int, long long int>)'
   60 |         G[v].push_back(make_pair(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 = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; value_type = std::vector<std::pair<long long int, long long 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 'std::pair<long long int, long long int>' to 'const std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&' {aka 'const std::vector<std::pair<long long int, long long 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::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; value_type = std::vector<std::pair<long long int, long long 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 'std::pair<long long int, long long int>' to 'std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::vector<std::pair<long long int, long long int> >&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~