Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    ll n;
    cin>>n;
    vector<vector<P>> v(n);
    for(ll i=0;i<n-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back({b,c});
        v[b].push_back({a,c});        
    } 
    //BFS
    vector<ll> col(n),visit(n);
    queue<ll> q;
    ll sum=0;
    col[0]=0;
    q.push(0);
    visit[0]=1;
    while(q.empty()!=1){
        ll tmp=q.front(); 
        q.pop();
        for(ll j=0;j<v[tmp].size();j++){
            ll a=v[tmp][j].first,b=v[tmp][j].second;
            if(visit[a]==0){
                if(b%2==0) col[v[a]]=col[tmp];
                else col[a]=1-col[tmp];
                q.push(a);
                visit[a]=1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout<<col[i]<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:31: error: no match for 'operator[]' (operand types are 'std::vector<long long int>' and '__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> >'})
   35 |                 if(b%2==0) col[v[a]]=col[tmp];
      |                               ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '__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 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '__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 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~