Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
bool W[100000][100000];
vector<int> G[100000];
bool ans[100000];
bool used[100000];
void add_edge(int u,int v,bool w){
    G[u].push_back(v);
    G[v].push_back(u);
    W[u][v]=w;
    W[v][u]=w;
}
bool dfs(int u,bool c){
    used[u]=true;
    if(G[u].size()==0) return true;
    for(int i=0;i<G[u].size();i++){
        if(used[i]==true)continue;
        if((W[u][i]==true&&c==true)||(W[u][i]==false&&c==false)){
            c=true;
            ans[i]=true;
        }
        else{
            c=false;
            ans[i]=false;
        }
        dfs(G[u][i],c);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int start;
    for(int i=0;i<n;i++) {
        int u,v;
        ll w1;
        bool w;
        cin>>u>>v>>w1;
        if(w1%2==0) w=true;
        else w=false;
        add_edge(u,v,w);
        if(i==0) start=u;
    }
    for(int i=0;i<n;i++){
        used[i]=false;
    }
    ans[start]= false;
    bool a=dfs(start,false);
    for(int i=0;i<n;i++){
        if(ans[i]==true)
        cout<<"1"<<"\n";
        else
        cout<<"0"<<"\n";
    }
}

Compiler output:
a.cc: In function 'bool dfs(int, bool)':
a.cc:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
/tmp/cc5yikhI.o: in function `add_edge(int, int, bool)':
a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc5yikhI.o
/tmp/cc5yikhI.o: in function `dfs(int, bool)':
a.cc:(.text+0xd1): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0xef): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x1c0): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc5yikhI.o
/tmp/cc5yikhI.o: in function `main':
a.cc:(.text+0x323): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc5yikhI.o
a.cc:(.text+0x342): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status