Language: C++

//ABC 126 D
#include <bits/stdc++.h>
using namespace std;

const long long max_n = 100010;
long long n, c[max_n];
vector<pair<long long, long long> > t[max_n];

void dfs(long long v, long long previous = -1) {
    for (int it=0; it<t[v].size(); ++it) {
        long long u = it.first;
        long long w = it.second % 2;
        if (u != previous) {
            c[u] = c[v] ^ w;
            dfs(u, v);
        }
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n - 1; ++i) {
        long long u, v, w;
        cin >> u >> v >> w;
        t[u].push_back(make_pair(v, w));
        t[v].push_back(make_pair(u, w));
    }
    
    dfs(1);
    
	for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }
    return 0;
}



//ABC 126 D
#include <bits/stdc++.h>
using namespace std;

const long long max_n = 100010;
long long n, c[max_n];
vector<pair<long long, long long> > t[max_n];

void dfs(long long v, long long previous = -1) {
    for (int it=0; it<t[v].size(); ++it) {
        long long u = it.first;
        long long w = it.second % 2;
        if (u != previous) {
            c[u] = c[v] ^ w;
            dfs(u, v);
        }
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n - 1; ++i) {
        long long u, v, w;
        cin >> u >> v >> w;
        t[u].push_back(make_pair(v, w));
        t[v].push_back(make_pair(u, w));
    }
    
    dfs(1);
    
	for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }
    return 0;
}





Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:11:26: error: request for member 'first' in 'it', which is of non-class type 'int'
   11 |         long long u = it.first;
      |                          ^~~~~
a.cc:12:26: error: request for member 'second' in 'it', which is of non-class type 'int'
   12 |         long long w = it.second % 2;
      |                          ^~~~~~
a.cc: At global scope:
a.cc:44:17: error: redefinition of 'const long long int max_n'
   44 | const long long max_n = 100010;
      |                 ^~~~~
a.cc:5:17: note: 'const long long int max_n' previously defined here
    5 | const long long max_n = 100010;
      |                 ^~~~~
a.cc:45:11: error: redefinition of 'long long int n'
   45 | long long n, c[max_n];
      |           ^
a.cc:6:11: note: 'long long int n' previously declared here
    6 | long long n, c[max_n];
      |           ^
a.cc:45:14: error: redefinition of 'long long int c [100010]'
   45 | long long n, c[max_n];
      |              ^
a.cc:6:14: note: 'long long int c [100010]' previously declared here
    6 | long long n, c[max_n];
      |              ^
a.cc:46:37: error: redefinition of 'std::vector<std::pair<long long int, long long int> > t [100010]'
   46 | vector<pair<long long, long long> > t[max_n];
      |                                     ^
a.cc:7:37: note: 'std::vector<std::pair<long long int, long long int> > t [100010]' previously declared here
    7 | vector<pair<long long, long long> > t[max_n];
      |                                     ^
a.cc:48:6: error: redefinition of 'void dfs(long long int, long long int)'
   48 | void dfs(long long v, long long previous = -1) {
      |      ^~~
a.cc:9:6: note: 'void dfs(long long int, long long int)' previously defined here
    9 | void dfs(long long v, long long previous = -1) {
      |      ^~~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:50:26: error: request for member 'first' in 'it', which is of non-class type 'int'
   50 |         long long u = it.first;
      |                          ^~~~~
a.cc:51:26: error: request for member 'second' in 'it', which is of non-class type 'int'
   51 |         long long w = it.second % 2;
      |                          ^~~~~~
a.cc: At global scope:
a.cc:59:5: error: redefinition of 'int main()'
   59 | int main() {
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main() {
      |     ^~~~