criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

void dfs(ll v, ll previous=-1) {
    for (auto it: t[v]) {
        ll u = it.first;
        ll 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) {
        ll u, v, w;
        cin >> u >> v >> w;
        t[u].push_back({v, w});
        t[v].push_back({u, w});
    }
    dfs(1);
    for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:31:6: error: expected '}' at end of input
   31 |     }
      |      ^
a.cc:20:12: note: to match this '{'
   20 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll max_n = 100010;
ll n, c[max_n];
vector<pair<ll, ll>> tree[max_n];

void dfs(ll v, ll previous=-1) {
    for (auto it: t[v]) {
        ll u = it.first;
        ll 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) {
        ll u, v, w;
        cin >> u >> v >> w;
        t[u].push_back({v, w});
        t[v].push_back({u, w});
    }
    dfs(1);
    for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(ll, ll)':
a.cc:10:19: error: 't' was not declared in this scope; did you mean 'it'?
   10 |     for (auto it: t[v]) {
      |                   ^
      |                   it
a.cc: In function 'int main()':
a.cc:25:9: error: 't' was not declared in this scope
   25 |         t[u].push_back({v, w});
      |         ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

bool graph[100005][100005],visited[100005];
int dis[100005][100005],color[100005];

void dfs(int v,int n) {
	visited[v] = true;
	for (int i = 2; i <= n; ++i) {
		if (graph[v][i] == false)continue;
		if (visited[i])continue;
		if (dis[v][i] % 2 == 0)color[i] = color[v];
		else color[i] = 1 - color[v];
		dfs(i, n);
	}
}
int main() {
	int n;
	cin >> n;
	vector<int>u(n+1), v(n+1), w(n+1);
	for (int i = 1; i < n ; ++i) {
		cin >> u[i] >> v[i] >> w[i];
		graph[u[i]][v[i]] = true;
		graph[v[i]][u[i]] = true;
		dis[u[i]][v[i]] = w[i];
		dis[v[i]][u[i]] = w[i];
	}
	color[1] = 0;
	dfs(1, n);
	for (int i = 1; i <= n; ++i)cout << color[i] << endl;
	return 0;
}

Compiler output:
/tmp/ccE06aPq.o: in function `dfs(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0xad): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0xde): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0xfe): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccE06aPq.o
/tmp/ccE06aPq.o: in function `main':
a.cc:(.text+0x35e): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0x3e1): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccE06aPq.o
a.cc:(.text+0x411): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
#define N_MAX 100005

bool graph[N_MAX][N_MAX],visited[N_MAX];
int dis[N_MAX][N_MAX],color[N_MAX];

void dfs(int v,int n) {
	visited[v] = true;
	for (int i = 2; i <= n; ++i) {
		if (graph[v][i] == false)continue;
		if (visited[i])continue;
		if (dis[v][i] % 2 == 0)color[i] = color[v];
		else color[i] = 1 - color[v];
		dfs(i, n);
	}
}
int main() {
	int n;
	cin >> n;
	vector<int>u(n+1), v(n+1), w(n+1);
	for (int i = 1; i < n ; ++i) {
		cin >> u[i] >> v[i] >> w[i];
		graph[u[i]][v[i]] = true;
		graph[v[i]][u[i]] = true;
		dis[u[i]][v[i]] = w[i];
		dis[v[i]][u[i]] = w[i];
	}
	color[1] = 0;
	dfs(1, n);
	for (int i = 1; i <= n; ++i)cout << color[i] << endl;
	return 0;
}

Compiler output:
/tmp/ccgAUP32.o: in function `dfs(int, int)':
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0xad): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0xde): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0xfe): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccgAUP32.o
/tmp/ccgAUP32.o: in function `main':
a.cc:(.text+0x35e): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0x3e1): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccgAUP32.o
a.cc:(.text+0x411): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

using P = pair<int, int>;

constexpr int MAX_N = 1e5 + 7;

int N;
int edges[MAX_N+1][MAX_N+1];
int colors[MAX_N+1];

void dfs(int cur) {

  for (int i{1}; i <= N; ++i) {
    if (colors[i] >= 0 || edges[cur][i] == 0)
      continue;
    colors[i] = edges[cur][i] % 2 == 0 ? colors[cur] : !colors[cur];
    dfs(i);
  }
}

int main() {
  fill_n(colors, MAX_N+1, -1);

  cin >> N;

  int u, v, w;
  for (int i{}; i < N - 1; ++i) {
    cin >> u >> v >> w;
    edges[u][v] = edges[v][u] = w;
  }

  colors[u] = 0;
  dfs(u);
  for (int i{1}; i <= N; ++i) {
    cout << colors[i] << endl;
  }
}


Compiler output:
/tmp/ccDEqXE9.o: in function `dfs(int)':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
a.cc:(.text+0xdc): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
/tmp/ccDEqXE9.o: in function `main':
a.cc:(.text+0x125): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
a.cc:(.text+0x22a): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
a.cc:(.text+0x258): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccDEqXE9.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> u(N);
  vector<int> v(N);
  vector<int> w(N);
  vector<int> ans(N,2);
  
  for(int i = 0; i < N; i++){
    cin >> u[i] >> v[i] >> w[i];
  }
  
  N[0] = 0;
  
  //最初1から探索して偶奇に応じて0or1を入力,入力し終わったら2or3を入れておく
  //0or1を探索して終わったら2or3を入れておくのを繰り返し
  //最後に０，２なら０を、１，３なら１を出力
  

Compiler output:
a.cc: In function 'int main()':
a.cc:16:4: error: invalid types 'int[int]' for array subscript
   16 |   N[0] = 0;
      |    ^
a.cc:16:12: error: expected '}' at end of input
   16 |   N[0] = 0;
      |            ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <iostream>

using namespace std;

int main(void) {
    int n, u, v, w;
    cin >> n;
    cout << n << endl;
    int N[n+1];
    memset(N, 0xff, sizeof(N));

    while(1) {
        cin >> u >> v >> w;
        if( cin.eof() ){
            break;
        }
        cout << u << " " << v << " " << w << endl;
        if ( N[u] == -1 && N[v] == -1 ){
            cout << "-1-" << endl;
            N[u] = N[v] = (w%2);
        }
        else if (N[u] != -1 && N[v] == -1) {
            cout << "-2-" << endl;
            N[v] = w%2 ? (N[u]+1)%2 : N[u];
        }
        else if (N[u] == -1 && N[v] != -1) {
            cout << "-3-" << endl;
            N[u] = w%2 ? (N[v]+1)%2 : N[v];
        }
    }
    for( int i = 1; i<=n; i++ ){
        cout << N[i] << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'memset' was not declared in this scope
   10 |     memset(N, 0xff, sizeof(N));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

public class Main {

  Node[] tree;
  boolean[] visited ;
  int[] colors;

  public static void main(String[] args) {

    new Main().run();
  }
  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out)) {

      int n = Integer.parseInt(in.readLine());
      tree = new Node[n];
      for (int i = 0; i < n; i++) {
        tree[i] = new Node(i);
      }
      String[] lines;
      for (int i = 0; i < n-1; i++) {
        lines = in.readLine().split(" ");
        int v = Integer.parseInt(lines[0]) - 1;
        int u = Integer.parseInt(lines[1]) - 1;
        int d = Integer.parseInt(lines[2]);
        tree[v].edge.add(new Edge(u, d));
        tree[u].edge.add(new Edge(v, d));
      }

      visited = new boolean[n];
      colors  = new int[n];
      Arrays.fill(colors, -1);

      bfs(0, 0);

      for (int c : colors) {
        out.println(c);
      }
      out.flush();
    }
    catch(IOException e) {

      System.err.println(e);
    }
  }

  void bfs(int fv, int fd) {
    Deque<Edge> stuck = new ArrayDeque<>();

    stuck.push(new Edge(fv, fd));

    while(!stuck.isEmpty()) {
      Edge v = stuck.pop();

      if(!visited[v.v]) {
        visited[v.v] = true;
        int d = colors[v.v] = v.d % 2 == 0 ? 0 : 1;
        for (Edge e : tree[v.v].edge) {
          stuck.push(new Edge(e.u, d + e.d));
        }
      }
    }
  }

  private class Node {
    int v;
    List<Edge> edge;

    public Node(int v) {
      this.v = v;
      edge = new LinkedList<>();
    }
  }

  private class Edge {
    int u, d = -1;

    public Edge(int u, int d) {
      this.u = u;
      this.d = d;
    }
  }
}

Compiler output:
Main.java:66: error: cannot find symbol
      if(!visited[v.v]) {
                   ^
  symbol:   variable v
  location: variable v of type Main.Edge
Main.java:67: error: cannot find symbol
        visited[v.v] = true;
                 ^
  symbol:   variable v
  location: variable v of type Main.Edge
Main.java:68: error: cannot find symbol
        int d = colors[v.v] = v.d % 2 == 0 ? 0 : 1;
                        ^
  symbol:   variable v
  location: variable v of type Main.Edge
Main.java:69: error: cannot find symbol
        for (Edge e : tree[v.v].edge) {
                            ^
  symbol:   variable v
  location: variable v of type Main.Edge
4 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int now=0;
int q[100001];

void qin (int x){
  q[now]=x;
  now++;
}
int qout (void){
  if (now != 0){
	now--;
    return q[now];
  }
}
  
int main(){
  int n;
  cin >> n;
  int d[n-1][n-1];
  int u,v,w;
  for (int i=0; i<n-1; i++){
    cin >> u >> v >> w;
    d[u-1][v-1] = w;
    d[v-1][u-1] = w;
  }
  // 1.今の場所から塗りつぶし未完了の頂点を探し、あれば塗りつぶしそこに移動して1に戻る 
  // 2.なければ一つ戻り同じことをする。
  int count=1;
  int np=0;
  int ans[n];
  for (int x: ans){
    x=-1;
  }
  ans[0]=0;
  bool flag = false;
  while (count < n){
    flag = true;
    for (int i=0; i<n; i++){
      if (ans[i]==-1 && d[np][i]!=0){
        ans[i] = (ans[np] + d[np][i]%2) % 2;
        qin(np);
        np = i;
        count++;
        flag = true
        break;
      }
    }
    if (flag)break;
    np = qout();
  }
  for (int x: ans){
    cout << x << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:20: error: expected ';' before 'break'
   45 |         flag = true
      |                    ^
      |                    ;
   46 |         break;
      |         ~~~~~       
a.cc: In function 'int qout()':
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
   15 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int now=0;
int q[100001];

void qin (int x){
  q[now]=x;
  now++;
}
int qout (void){
  if (now != 0){
	now--;
    return q[now];
  }
}
  
int main(){
  int n;
  cin >> n;
  int d[n-1][n-1];
  int u,v,w;
  for (int i=0; i<n-1; i++){
    cin >> u >> v >> w;
    d[u-1][v-1] = w;
    d[v-1][u-1] = w;
  }
  // 1.今の場所から塗りつぶし未完了の頂点を探し、あれば塗りつぶしそこに移動して1に戻る 
  // 2.なければ一つ戻り同じことをする。
  int count=1;
  int np=0;
  int ans[n];
  for (int x: a){
    x=-1;
  }
  ans[0]=0;
  bool flag = false;
  while (count < n){
    flag = true;
    for (int i=0; i<n; i++){
      if (ans[i]==-1 && d[np][i]!=0){
        ans[i] = (ans[np] + d[np][i]%2) % 2;
        qin(np);
        np = i;
        count++;
        flag = true
        break;
      }
    }
    if (flaf)break;
    np = qout();
  }
  for (int x: ans){
    cout << x << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:15: error: 'a' was not declared in this scope
   32 |   for (int x: a){
      |               ^
a.cc:45:20: error: expected ';' before 'break'
   45 |         flag = true
      |                    ^
      |                    ;
   46 |         break;
      |         ~~~~~       
a.cc:49:9: error: 'flaf' was not declared in this scope; did you mean 'flag'?
   49 |     if (flaf)break;
      |         ^~~~
      |         flag
a.cc: In function 'int qout()':
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
   15 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;

void dfs(vp e[], int x, int p, int dis[]) {
    for (pii y : e[x]) {
        if (y.first != p) {
            dis[y.first] = dis[x] + y.second;
            dis[y.first] %= 2;
            dfs(e, y, x, dis);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vp e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        e[u].push_back({v, w});
        e[v].push_back({u, w});
    }

    int dis[n];
    dis[0] = 0;
    dfs(e, 0, -1, dis);

    for (int i = 0; i < n; i++) {
        cout << dis[i] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void dfs(vp*, int, int, int*)':
a.cc:15:20: error: cannot convert 'pii' {aka 'std::pair<int, int>'} to 'int'
   15 |             dfs(e, y, x, dis);
      |                    ^
      |                    |
      |                    pii {aka std::pair<int, int>}
a.cc:10:22: note:   initializing argument 2 of 'void dfs(vp*, int, int, int*)'
   10 | void dfs(vp e[], int x, int p, int dis[]) {
      |                  ~~~~^
Language: C++

#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;

void dfs(vp e[], int x, int p, int dis[]) {
    for (int y : e[x]) {
        if (y.first != p) {
            dis[y.first] = dis[x] + y.second;
            dis[y.first] %= 2;
            dfs(e, y, x, dis);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vp e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        e[u].push_back({v, w});
        e[v].push_back({u, w});
    }

    int dis[n];
    dis[0] = 0;
    dfs(e, 0, -1, dis);

    for (int i = 0; i < n; i++) {
        cout << dis[i] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void dfs(vp*, int, int, int*)':
a.cc:11:21: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   11 |     for (int y : e[x]) {
      |                     ^
a.cc:12:15: error: request for member 'first' in 'y', which is of non-class type 'int'
   12 |         if (y.first != p) {
      |               ^~~~~
a.cc:13:19: error: request for member 'first' in 'y', which is of non-class type 'int'
   13 |             dis[y.first] = dis[x] + y.second;
      |                   ^~~~~
a.cc:13:39: error: request for member 'second' in 'y', which is of non-class type 'int'
   13 |             dis[y.first] = dis[x] + y.second;
      |                                       ^~~~~~
a.cc:14:19: error: request for member 'first' in 'y', which is of non-class type 'int'
   14 |             dis[y.first] %= 2;
      |                   ^~~~~
Language: C++

int color[100000];
bool used[100000];
int N;

void f(int u)
{
  if(used[u])return;
  used[u]=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm[u][i].second;
    if(w & 1){
      color[to]=(color[u]?0:1);
       }
      else
      {
        color[to]=color[u];
      }
    f(to);
  }
  
}



int main()
{
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_back({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color[i+1]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:9:15: error: 'vm' was not declared in this scope
    9 |   for(int i=0;vm[u].size();i++)
      |               ^~
a.cc: In function 'int main()':
a.cc:29:3: error: 'cin' was not declared in this scope
   29 |   cin>>N;
      |   ^~~
a.cc:34:3: error: 'vm' was not declared in this scope; did you mean 'vx'?
   34 |   vm[ux].push_back({vx,wx});
      |   ^~
      |   vx
a.cc:40:3: error: 'cout' was not declared in this scope
   40 |   cout<<color[i+1]<<endl;
      |   ^~~~
a.cc:40:21: error: 'endl' was not declared in this scope
   40 |   cout<<color[i+1]<<endl;
      |                     ^~~~
Language: C++

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

vector<pair<int,int>> vm[100000];
int color(1000000);
bool used(1000000);
int N;

void f(int u)
{
  if(used[u])return;
  used[u]=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm[u][i].second;
    if(w & 1){
      if(color[u]==1){color[to]=0;}
      if(color[u]==0){color[to]=1;}
       }
      else
      {
        color[to]=color[u];
      }
    f(to);
  }
  
}



int main()
{
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_back({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color[i+1]<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:11:10: error: invalid types 'bool[int]' for array subscript
   11 |   if(used[u])return;
      |          ^
a.cc:12:7: error: invalid types 'bool[int]' for array subscript
   12 |   used[u]=1;
      |       ^
a.cc:18:15: error: invalid types 'int[int]' for array subscript
   18 |       if(color[u]==1){color[to]=0;}
      |               ^
a.cc:18:28: error: invalid types 'int[int]' for array subscript
   18 |       if(color[u]==1){color[to]=0;}
      |                            ^
a.cc:19:15: error: invalid types 'int[int]' for array subscript
   19 |       if(color[u]==0){color[to]=1;}
      |               ^
a.cc:19:28: error: invalid types 'int[int]' for array subscript
   19 |       if(color[u]==0){color[to]=1;}
      |                            ^
a.cc:23:14: error: invalid types 'int[int]' for array subscript
   23 |         color[to]=color[u];
      |              ^
a.cc:23:24: error: invalid types 'int[int]' for array subscript
   23 |         color[to]=color[u];
      |                        ^
a.cc: In function 'int main()':
a.cc:45:14: error: invalid types 'int[int]' for array subscript
   45 |   cout<<color[i+1]<<endl;
      |              ^
Language: C++

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

vector<pair<int,int>> vm[100000];
int color[1000000];
bool used[1000000];
int N;

void f(int u)
{
  if(used[u])return;
  used[u]=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm[u][i].second;
    if(w & 1){
      if(color[u]==1){color[to]=0;}
      if(color[u]==0){color[to]=1;}
       }
      else
      {
        color[to]=color[u];
      }
    f(to);
  }
  
}



int main()
{
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_back({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:15: error: request for member 'at' in 'color', which is of non-class type 'int [1000000]'
   45 |   cout<<color.at(i+1)<<endl;
      |               ^~
Language: C++

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

vector<pair<int,int>> vm[100000];
int color(1000000);
bool used(1000000);
int N;

void f(int u)
{
  if(used[u])return;
  used[u]=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm[u][i].second;
    if(w & 1){
      if(color[u]==1){color[to]=0;}
      if(color[u]==0){color[to]=1;}
       }
      else
      {
        color[to]=color[u];
      }
    f(to);
  }
  
}



int main()
{
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_back({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:11:10: error: invalid types 'bool[int]' for array subscript
   11 |   if(used[u])return;
      |          ^
a.cc:12:7: error: invalid types 'bool[int]' for array subscript
   12 |   used[u]=1;
      |       ^
a.cc:18:15: error: invalid types 'int[int]' for array subscript
   18 |       if(color[u]==1){color[to]=0;}
      |               ^
a.cc:18:28: error: invalid types 'int[int]' for array subscript
   18 |       if(color[u]==1){color[to]=0;}
      |                            ^
a.cc:19:15: error: invalid types 'int[int]' for array subscript
   19 |       if(color[u]==0){color[to]=1;}
      |               ^
a.cc:19:28: error: invalid types 'int[int]' for array subscript
   19 |       if(color[u]==0){color[to]=1;}
      |                            ^
a.cc:23:14: error: invalid types 'int[int]' for array subscript
   23 |         color[to]=color[u];
      |              ^
a.cc:23:24: error: invalid types 'int[int]' for array subscript
   23 |         color[to]=color[u];
      |                        ^
a.cc: In function 'int main()':
a.cc:45:15: error: request for member 'at' in 'color', which is of non-class type 'int'
   45 |   cout<<color.at(i+1)<<endl;
      |               ^~
Language: C++

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

vector<pair<int,int>> vm[100000];
int color(1000000);
bool used(1000000);
int N;

void f(int u)
{
  if(used[u]return;
  used[u]=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm[u][i].second;
    if(w%2==1 & 1){
      if(color[to]==1){color[u]=0;}
      if(color[to]==0){color[u]=1;}
       }
    else{color[to]=color[u];}
    f(to);
  }
  
}



int main()
{
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_back({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:11:10: error: invalid types 'bool[int]' for array subscript
   11 |   if(used[u]return;
      |          ^
a.cc:12:7: error: invalid types 'bool[int]' for array subscript
   12 |   used[u]=1;
      |       ^
a.cc:12:12: error: expected ')' before ';' token
   12 |   used[u]=1;
      |            ^
      |            )
a.cc:11:5: note: to match this '('
   11 |   if(used[u]return;
      |     ^
a.cc:18:15: error: invalid types 'int[int]' for array subscript
   18 |       if(color[to]==1){color[u]=0;}
      |               ^
a.cc:18:29: error: invalid types 'int[int]' for array subscript
   18 |       if(color[to]==1){color[u]=0;}
      |                             ^
a.cc:19:15: error: invalid types 'int[int]' for array subscript
   19 |       if(color[to]==0){color[u]=1;}
      |               ^
a.cc:19:29: error: invalid types 'int[int]' for array subscript
   19 |       if(color[to]==0){color[u]=1;}
      |                             ^
a.cc:21:15: error: invalid types 'int[int]' for array subscript
   21 |     else{color[to]=color[u];}
      |               ^
a.cc:21:25: error: invalid types 'int[int]' for array subscript
   21 |     else{color[to]=color[u];}
      |                         ^
a.cc: In function 'int main()':
a.cc:42:15: error: request for member 'at' in 'color', which is of non-class type 'int'
   42 |   cout<<color.at(i+1)<<endl;
      |               ^~
Language: C++

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

vector<pair<int,int>> vm[100000];
vector<int> color(1000000);
vector<bool> used(1000000);


void f(int u)
{
  if(used.at(u))return;
  used.at(u)=1;
  for(int i=0;vm[u].size();i++)
  {
    int to=vm[u][i].first;
    int w=vm.[u][i].second;
    if(w%2==1){
      if(color.at(to)==1){color.at(u)=0;}
      if(color.at(to)==0){color.at(u)=1;}
       }
    else{color.at(to)=color.at(u);}
  }
  f(to);
}



int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
  vm[ux].push_back({vx,wx});
  vm[vx].push_buck({ux,wx});
  
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<color.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:16:14: error: expected unqualified-id before '[' token
   16 |     int w=vm.[u][i].second;
      |              ^
a.cc:23:5: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |   f(to);
      |     ^~
      |     tm
a.cc: In function 'int main()':
a.cc:37:10: error: 'class std::vector<std::pair<int, int> >' has no member named 'push_buck'; did you mean 'push_back'?
   37 |   vm[vx].push_buck({ux,wx});
      |          ^~~~~~~~~
      |          push_back
Language: C++

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

vector<pair<int,int>> vm(1000000);
vector<int> color(1000000);
vector<bool> used(1000000);


void f(int u)
{
  if(used.at(u))return;
  used.at(u)=1;
  for(int i=0;i<vm.size();i++)
  {
    int to=vm.at(u).at(i).first;
    int w=vm.at(u).at(i).second;
    if(w%2==1){
      if(color.at(to)==1){color.at(u)=0;}
      if(color.at(to)==0){color.at(u)=1;}
       }
    else{color.at(to)=color.at(u);}
  }
  f(to);
}



int main()
{
  int N;
  cin>>N;
  vector<int>tree(N,vw);
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
    tree.at(ux).vm={vx,wx};
    tree.at(vx).w1={ux,wx};
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<iro.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:15:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'at'
   15 |     int to=vm.at(u).at(i).first;
      |                     ^~
a.cc:16:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'at'
   16 |     int w=vm.at(u).at(i).second;
      |                    ^~
a.cc:23:5: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |   f(to);
      |     ^~
      |     tm
a.cc: In function 'int main()':
a.cc:32:21: error: 'vw' was not declared in this scope; did you mean 'vm'?
   32 |   vector<int>tree(N,vw);
      |                     ^~
      |                     vm
a.cc:37:17: error: request for member 'vm' in 'tree.std::vector<int>::at(((std::vector<int>::size_type)ux))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   37 |     tree.at(ux).vm={vx,wx};
      |                 ^~
a.cc:38:17: error: request for member 'w1' in 'tree.std::vector<int>::at(((std::vector<int>::size_type)vx))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   38 |     tree.at(vx).w1={ux,wx};
      |                 ^~
a.cc:42:9: error: 'iro' was not declared in this scope
   42 |   cout<<iro.at(i+1)<<endl;
      |         ^~~
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int N;
vector<vector<int>> to(100000),co(100000);
vector<bool> on(100000,false);
int dfs(int a);
void solve();
int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        to[u].push_back(v);co[u].push_back(w);
        to[v].push_back(u);co[v].push_back(w);
    }
    solve();
}

int dfs(int a){//bugged
    if(a>N) return -1;
    if(a==0) return 0;
    on[a]=true;
    int ret=-1;
    int w;
    for(int i=0;i<to[a].size();i++){
        int b = to[a][i];
        w = co[a][i];
        if(!on[b]) ret = dfs(b);
        if(ret!=-1) break;
    }
    on[a]=false;
    if(ret==-1) return ret;
    return (ret+w)%2;
}

void solve(){
    ans[0]=0;
    for(int i=0;i<N;i++) cout << dfs(i) << endl;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:45:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |     ans[0]=0;
      |     ^~~
      |     abs
Language: C++

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

vector<pair<int,int>> vm(1000000);
vector<int> color(1000000);
vector<bool> used(1000000);


void f(int u)
{
  if(used.at(u))return;
  used.at(u)=1;
  for(int i=0;i<vm.size();i++)
  {
    int to=vm.at(u).at(i).first;
    int w=vm.at(u).at(i).second;
    if(w%2==1){
      if(color.at(to)==1){color.at(u)=0;}
      if(color.at(to)==0){color.at(u)=1;}
       }
    else{color.at(to)=color.at(u);}
  }
  f(to);
}



int main()
{
  int N;
  cin>>N;
  vector<vector<int>>tree(N,vw);
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
    tree.at(ux).vm={vx,wx};
    tree.at(vx).w1={ux,wx};
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<iro.at(i+1)<<endl;
  }
}

Compiler output:
a.cc: In function 'void f(int)':
a.cc:15:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'at'
   15 |     int to=vm.at(u).at(i).first;
      |                     ^~
a.cc:16:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'at'
   16 |     int w=vm.at(u).at(i).second;
      |                    ^~
a.cc:23:5: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |   f(to);
      |     ^~
      |     tm
a.cc: In function 'int main()':
a.cc:32:29: error: 'vw' was not declared in this scope; did you mean 'vm'?
   32 |   vector<vector<int>>tree(N,vw);
      |                             ^~
      |                             vm
a.cc:37:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'vm'
   37 |     tree.at(ux).vm={vx,wx};
      |                 ^~
a.cc:38:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'w1'
   38 |     tree.at(vx).w1={ux,wx};
      |                 ^~
a.cc:42:9: error: 'iro' was not declared in this scope
   42 |   cout<<iro.at(i+1)<<endl;
      |         ^~~
Language: C++

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

struct vw{int v1; int w1;}
vector<int> color(N+1)
vector<bool> used(N+1)


void f(int u)
{
  if(used.at(u))return;
  used.at(u)=1;
  for(int go,int w:tree.at(u))
  {
    if(w%2==1){
      if(color.at(to)==1){color.at(u)=0;}
      if(color.at(to)==0){color.at(u)=1;}
       }
    else{color.at(to)=color.at(u);}
  }
  f(to);
}



int main()
{
  int N;
  cin>>N;
  vector<vector<int>>tree(N,vw);
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
    tree.at(ux).vm={vx,wx};
    tree.at(vx).w1={ux,wx};
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<iro.at(i+1)<<endl;
  }
}

Compiler output:
a.cc:5:13: error: invalid declarator before 'color'
    5 | vector<int> color(N+1)
      |             ^~~~~
a.cc: In function 'int main()':
a.cc:30:31: error: expected primary-expression before ')' token
   30 |   vector<vector<int>>tree(N,vw);
      |                               ^
a.cc:35:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'vm'
   35 |     tree.at(ux).vm={vx,wx};
      |                 ^~
a.cc:36:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'w1'
   36 |     tree.at(vx).w1={ux,wx};
      |                 ^~
a.cc:38:1: error: 'f' was not declared in this scope
   38 | f(1);
      | ^
a.cc:40:9: error: 'iro' was not declared in this scope
   40 |   cout<<iro.at(i+1)<<endl;
      |         ^~~
Language: C++

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

struct vw{int v1; int w1;}
vcetor<int> color(N+1)
vector<bool> used(N+1)


void f(int u)
{
  if(used.at(u))return;
  used.at(u)=1;
  for(int go,int w:tree.at(u))
  {
    if(w%2==1){
      if(color.at(to)==1){color.at(u)=0;}
      if(color.at(to)==0){color.at(u)=1;}
       }
    else{color.at(to)=color.at(u);}
  }
  f(to);
}



int main()
{
  int N;
  cin>>N;
  vector<vector<int>>tree(N,vw);
  for(int i=0;i<N;i++)
  {
    int ux,vx,wx;
    cin>>ux>>vx>>wx;
    tree.at(ux).vm={vx,wx};
    tree.at(vx).w1={ux,wx};
  }
f(1);
for(int i=0;i<N;i++){  
  cout<<iro.at(i+1)<<endl;
  }
}

Compiler output:
a.cc:5:7: error: expected initializer before '<' token
    5 | vcetor<int> color(N+1)
      |       ^
a.cc: In function 'int main()':
a.cc:30:31: error: expected primary-expression before ')' token
   30 |   vector<vector<int>>tree(N,vw);
      |                               ^
a.cc:35:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'vm'
   35 |     tree.at(ux).vm={vx,wx};
      |                 ^~
a.cc:36:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'w1'
   36 |     tree.at(vx).w1={ux,wx};
      |                 ^~
a.cc:38:1: error: 'f' was not declared in this scope
   38 | f(1);
      | ^
a.cc:40:9: error: 'iro' was not declared in this scope
   40 |   cout<<iro.at(i+1)<<endl;
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int d[100001][100001];
int answer[100001];
void tansaku(int x,int r){
  for (int i=0; i<x; i++){
  	if (d[r][i] != 0 && answer[i] == -1){
      answer [i] = d[r][i] % 2;
      tansaku (x , i);
    }
  }
}
int main(){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    answer[i]=-1;
  }  
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
  }
  tansaku(n,0);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    


Compiler output:
/tmp/ccpX1FLF.o: in function `tansaku(int, int)':
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccpX1FLF.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccpX1FLF.o
/tmp/ccpX1FLF.o: in function `main':
a.cc:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccpX1FLF.o
a.cc:(.text+0x1f5): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccpX1FLF.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int d[100001][100001];
int answer[100001];
void tansaku(int n,int r){
  for (int i=0; i<n; i++){
  	if (d[r][i] != 0 && answer[i] == -1){
      answer [i] = d[r][i] % 2;
      tansaku (n , i);
    }
  }
}
int main(){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    answer[i]=-1;
  }  
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
  }
  tansaku(n,0);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    


Compiler output:
/tmp/ccmDTHnr.o: in function `tansaku(int, int)':
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccmDTHnr.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccmDTHnr.o
/tmp/ccmDTHnr.o: in function `main':
a.cc:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccmDTHnr.o
a.cc:(.text+0x1f5): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccmDTHnr.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int d[100001][100001];
int answer[100001];
void tansaku(int n,int r){
  for (int i=0; i<n; i++){
  	if (d[r][i] != 0 && answer[i] == -1){
      answer [i] = d[r][i] % 2;
      tansaku (n , r);
    }
  }
}
int main(){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    answer[i]=-1;
  }  
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
  }
  tansaku(n,0);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    


Compiler output:
/tmp/ccetHbOV.o: in function `tansaku(int, int)':
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccetHbOV.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccetHbOV.o
/tmp/ccetHbOV.o: in function `main':
a.cc:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccetHbOV.o
a.cc:(.text+0x1f5): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccetHbOV.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int d[100001][100001];
int answer[100001];
void tansaku(int n,int r){
  for (int i=0; i<n; i++){
  	if (d[r][i] != 0 && answer[i] == -1){
      answer [i] = d[r][i] % 2;
      tansaku (n , r);
    }
  }
}
int main(){
  cin >> n;
  for (int i=0; i<n; i++){
    answer[i]=-1;
  }  
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
  }
  tansaku(n,0);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   14 |   cin >> n;
      |          ^
      |          yn
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> p(100001);
int d[100001][100001];
int answer[100001];
int n;
int r(int x){
  if (p[x] == x)return x;
  else{
    return p[x] = r(p[x]);
  }
}
void tansaku(int x){
  for (int i=0; i<n; i++){
    if (p[i]==x && i!=x){
      answer[i]=d[i][x]%2;
      tansaku(i);
    }
  }
}
int main(){
  cin >> n;
  for (int i=0; i<n; i++){
    p[i]=i;
  }
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
    int ru=r(u);
    int rv=r(v);
    if (ru != rv){
      p[ru]=rv;
    }
  }
  int root;
  for (int i=0; i<n; i++){
    if (p[i]==i){
      root=i;
      break;
    }
  }
  answer[root]=0;
  tansaku(root);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    

Compiler output:
/tmp/ccRPIKxZ.o: in function `tansaku(int)':
a.cc:(.text+0x10c): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x123): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
/tmp/ccRPIKxZ.o: in function `main':
a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x2b1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x2f8): relocation truncated to fit: R_X86_64_PC32 against symbol `answer' defined in .bss section in /tmp/ccRPIKxZ.o
a.cc:(.text+0x328): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRPIKxZ.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> p(100001);
int d[100001][100001];
int answer[100001];
int n;
int r(int x){
  if (p[x] == x)return x;
  else{
    return p[x] = r(p[x]);
  }
}
void tansaku(int x){
  for (int i=0; i<n; i++){
    if (p[i]==x && i!=x){
      answer[i]=d[i][x]%2;
      tansaku(i);
    }
  }
}
int main(){
  cin >> n;
  for (int i=0; i<n; i++){
    p[i]=i;
  }
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
    int ru=r(u);
    int rv=r(v);
    if (ru != rv){
      p[ru]=rv;
    }
  }
  for (int i=0; i<n; i++){
    if (p[i]==i){
      int root=i;
      break;
    }
  }
  answer[root]=0;
  tansaku(root);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:43:10: error: 'root' was not declared in this scope
   43 |   answer[root]=0;
      |          ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> p(100001);
int d[100001][100001];
int answer[100001];
int r(int x){
  if (p[x] == x)return x;
  else{
    return p[x] = r(p[x]);
  }
}
void tansaku(int x){
  for (int i=0; i<n; i++){
    if (p[i]==x && i!=x){
      answer[i]=d[i][x]%2;
      tansaku(i);
    }
  }
}
int main(){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    p[i]=i;
  }
  for (int i=0; i<n; i++){
    int u,v,w;
    cin >>u>>v>>w;
    d[u][v]=w;
    d[v][u]=w;
    int ru=r(u);
    int rv=r(v);
    if (ru != rv){
      p[ru]=rv;
    }
  }
  for (int i=0; i<n; i++){
    if (p[i]==i){
      int root=i;
      break;
    }
  }
  answer[root]=0;
  tansaku(root);
  for (int i=0; i<n; i++){
    cout << answer[i] << endl;
  }
}
    

Compiler output:
a.cc: In function 'void tansaku(int)':
a.cc:13:19: error: 'n' was not declared in this scope
   13 |   for (int i=0; i<n; i++){
      |                   ^
a.cc: In function 'int main()':
a.cc:43:10: error: 'root' was not declared in this scope
   43 |   answer[root]=0;
      |          ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int nmax = 100005;
vector<int> A[nmax], B[nmax];

void DFS(int u, int N, int &color[])
{
	bool check = true;
	for (int i = 0; i < N; i++)
	{
		if (color[i] == 0)
		{
			check = false;
			break;
		}
	}
	if (check)
	{
		for (int i = 0; i < N; i++)
		{
			cout << color[i]%2 << endl;
		}
		return;
	}
	for (int i = 0; i < A[u].size(); i++)
	{
		if (color[A[u][i]] == 0)
		{
			color[A[u][i]] = color[u];
			DFS(A[u][i], N, color);
		}
	}
	for (int i = 0; i < B[u].size(); i++)
	{
		if (color[B[u][i]] == 0)
		{
			color[B[u][i]] = color[u] % 2 + 1;
			DFS(B[u][i], N, color);
		}
	}
	return;
}

int main()
{

	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		if (z % 2 == 0)
		{
			A[x - 1].push_back(y - 1);
			A[y - 1].push_back(x - 1);
		}
		else if (z % 2 == 1)
		{
			B[x - 1].push_back(y - 1);
			B[y - 1].push_back(x - 1);
		}
	}

	int color[nmax];
	color[0] = 2;
	DFS(0, N, color);
}


Compiler output:
a.cc:6:29: error: declaration of 'color' as array of references
    6 | void DFS(int u, int N, int &color[])
      |                             ^~~~~
a.cc: In function 'void DFS(...)':
a.cc:9:29: error: 'N' was not declared in this scope
    9 |         for (int i = 0; i < N; i++)
      |                             ^
a.cc:11:21: error: 'color' was not declared in this scope
   11 |                 if (color[i] == 0)
      |                     ^~~~~
a.cc:19:37: error: 'N' was not declared in this scope
   19 |                 for (int i = 0; i < N; i++)
      |                                     ^
a.cc:21:33: error: 'color' was not declared in this scope
   21 |                         cout << color[i]%2 << endl;
      |                                 ^~~~~
a.cc:25:31: error: 'u' was not declared in this scope
   25 |         for (int i = 0; i < A[u].size(); i++)
      |                               ^
a.cc:27:21: error: 'color' was not declared in this scope
   27 |                 if (color[A[u][i]] == 0)
      |                     ^~~~~
a.cc:30:38: error: 'N' was not declared in this scope
   30 |                         DFS(A[u][i], N, color);
      |                                      ^
a.cc:33:31: error: 'u' was not declared in this scope
   33 |         for (int i = 0; i < B[u].size(); i++)
      |                               ^
a.cc:35:21: error: 'color' was not declared in this scope
   35 |                 if (color[B[u][i]] == 0)
      |                     ^~~~~
a.cc:38:38: error: 'N' was not declared in this scope
   38 |                         DFS(B[u][i], N, color);
      |                                      ^