Pagini recente » Cod sursa (job #1714767) | Cod sursa (job #561334) | Cod sursa (job #1702867) | Cod sursa (job #1757755) | Cod sursa (job #3147047)
//https://www.infoarena.ro/problema/oz
#include <bits/stdc++.h>
using namespace std;
ifstream in("oz.in");
ofstream out("oz.out");
int main() {
ios_base::sync_with_stdio(false);
in.tie(NULL);
out.tie(NULL);
int n, m;
in >> n >> m;
vector<int>ans(n + 1);
while (m--) {
int i, j, d;
in >> i >> j >> d;
ans[i] ? ans[i] *= d : ans[i] = d;
ans[j] ? ans[j] *= d : ans[j] = d;
}
for (auto it : ans)
if (it)
out << it << ' ';
out << '\n';
return 0;
}