D ACed,but why WA before:
# include <bits/stdc++.h>
# define I return
# define AK 0
# define IOI ;
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int n, m, x, y, z;
vector <pii> v[200005];
ll ans[200005];
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> n >> m;
for (int i = 0; i < m; ++ i) {
cin >> x >> y >> z;
if (x > y)
swap (x, y), z = -z;
v[x].emplace_back (y, z);
}
for (int i = 1; i <= n; cout << ans[i] << ' ', ++ i)
for (const pii& j : v[i])
ans[j.first] = ans[i] + j.second;
I AK IOI
}