Language: C++

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }

bool visited[100002];
int steps[100002];
int edge[100002][100002];
ll N,u,v,w;

void dfs(ll prev, ll cur, ll cnt){
    // cntを増やす
    visited[cur] = true;
    cnt += edge[prev][cur];
    steps[cur] = cnt;
    //edgeで繋がっているかつvisitedでないノードにいく
    llRep(i,N){
        if (edge[cur][i] && !visited[i]){
            dfs(cur, i, cnt);
        }
    }
    return;
}

int main(){
    cin >> N;

    //initialize

    llrep(i,N-1){
        cin >> u >> v >> w;
        edge[u][v] = edge[v][u] = w;
    }
    //1からなんてで行けるかを調べる
    dfs(1,1,0);

    llRep(i,N){
        if (steps[i]%2==0){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
    }
    return 0;
}


Compiler output:
/tmp/ccXIFIJU.o: in function `dfs(long long, long long, long long)':
a.cc:(.text+0x3c2): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccXIFIJU.o
/tmp/ccXIFIJU.o: in function `main':
a.cc:(.text+0x3da): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x400): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x41c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x431): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x443): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x44a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x451): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x476): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x47d): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccXIFIJU.o
a.cc:(.text+0x4c1): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status