Cod sursa(job #2873049)
| Utilizator | Data | 18 martie 2022 15:34:51 | |
|---|---|---|---|
| Problema | Oz | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream cin ("oz.in");
ofstream cout ("oz.out");
int n,m,i,j;
unsigned long long v[10001],k;
int main()
{
int n,m;
cin>>n>>m;
while (m--){
cin>>i>>j>>k;
if (!v[i]) v[i]++;
v[i]*=k;
if (!v[j]) v[j]++;
v[j]*=k;
}
for (int i=1; i<=n; ++i)
if (!v[i]){
cout<<-1;
break;
}
for (int i=1; i<=n; ++i) cout<<v[i]<<" ";
return 0;
}
