Cod sursa(job #3147047)

Utilizator sorinturdaSorin Turda sorinturda Data 23 august 2023 21:50:43
Problema Oz Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
//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;
}