Language: C++

#include <stdio.h>

const int N = 131072;

int n, m;

struct edge {
	int to, weight;
};

struct node {
	edge e;
	node *next;
};

node nodes[N];
int currentCount = 0;
node *edges[N];
int p[N];
int count[N];
int distancePeople[N];

void addEdge(int from, int to, int weight) {
	edge e; e.to = to; e.weight = weight;
	//edges[from].push_back(e);
	node nod = nodes + currentCount++;
	nod->e = e;
	nod->next = edges[from];
	edges[from] = nod;
}

int getPart(int x) {
	return p[x];
}

void init() {
	for(int i = 0; i < N; i++) {
		p[i] = i;
		count[i] = 1;
	}
}

void DFS(int x, int d, int initialDistancePeople, int part) {
	distancePeople[x] = initialDistancePeople + d;
	p[x] = part;
	count[part]++;
	for(node p = edges[x]; p; p = p->next) {
		ed = p->e;
		if(p[ed.to] != part) {
			DFS(ed.to, ed.weight, distancePeople[x], part);
		}
	}
}

void unite(int x, int y, int d) {
	if(count[x] > count[y]) {
		DFS(y, d, distancePeople[x], getPart(x));
	} else {
		DFS(x, -d, distancePeople[y], getPart(y));
	}
	addEdge(x, y, d);
	addEdge(y, x, -d);
}

bool checkdistancePeople(int x, int y, int d) {
	//printf("%d %d\n", distancePeople[y] - distancePeople[x], d);
	return (distancePeople[y] - distancePeople[x]) == d;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		if(getPart(x) != getPart(y)) {
			unite(x, y, d);
		} else {
			if(!checkdistancePeople(x, y, d)) {
				printf("No\n");
				return 0;
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		printf("%d ", distancePeople[i]);
	}
	printf("\n");*/
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'void addEdge(int, int, int)':
a.cc:26:26: error: conversion from 'node*' to non-scalar type 'node' requested
   26 |         node nod = nodes + currentCount++;
      |                    ~~~~~~^~~~~~~~~~~~~~~~
a.cc:27:12: error: base operand of '->' has non-pointer type 'node'
   27 |         nod->e = e;
      |            ^~
a.cc:28:12: error: base operand of '->' has non-pointer type 'node'
   28 |         nod->next = edges[from];
      |            ^~
a.cc:29:23: error: cannot convert 'node' to 'node*' in assignment
   29 |         edges[from] = nod;
      |                       ^~~
      |                       |
      |                       node
a.cc: In function 'void DFS(int, int, int, int)':
a.cc:47:29: error: conversion from 'node*' to non-scalar type 'node' requested
   47 |         for(node p = edges[x]; p; p = p->next) {
      |                      ~~~~~~~^
a.cc:47:32: error: could not convert 'p' from 'node' to 'bool'
   47 |         for(node p = edges[x]; p; p = p->next) {
      |                                ^
      |                                |
      |                                node
a.cc:47:40: error: base operand of '->' has non-pointer type 'node'
   47 |         for(node p = edges[x]; p; p = p->next) {
      |                                        ^~
a.cc:48:17: error: 'ed' was not declared in this scope; did you mean 'd'?
   48 |                 ed = p->e;
      |                 ^~
      |                 d
a.cc:48:23: error: base operand of '->' has non-pointer type 'node'
   48 |                 ed = p->e;
      |                       ^~