Cod sursa(job #197679)
Utilizator | Taloi Bogdan Cristian taloibogdan | Data | 5 iulie 2008 13:49:20 |
---|---|---|---|
Problema | Reconst | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Junior Challenge 2008 | Marime | 0.5 kb |
#include<stdio.h>
long n,m,i,a,b,v,s[500][500],j;
int main()
{
freopen("reconst.in","r",stdin);
freopen("reconst.out","w",stdout);
scanf("%ld%ld",&n,&m);
for(i=1;i<=m;++i){scanf("%ld%ld%ld",&a,&b,&v);s[a][b]=v;}
for(i=1;i<=n;++i)
{
for(j=1;j<=i;++j)
if(s[j][n-i+j]==0)
{
if(j!=1)s[j][n-i+j]=s[j-1][n-i+j]-s[j-1][n-i+j-1];
else s[j][n-i+j]=1;
}
}
for(i=1;i<=n;++i)printf("%ld ",s[i][i]);
printf("\n");
return 0;
}