mafia's blog

By mafia, 12 years ago, In English

Could someone help me with this task. I have a solution but it is saying Runtime error. Could someone say why? Here is my code:

#include<stdio.h>
#include<algorithm>
using namespace std;
int d[2002][102][102];
int a[102][102],n,m;
main()
{
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    int i,j,k,l,v;
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    d[0][0][1]=1;
    for (l=1;l<=m;l++)
        {
        for (i=1;i<=n;i++)
            {
            for (j=1;j<=n;j++)
                {
                v=max(max(d[l-1][i-1][j],d[l-1][i+1][j]),max(d[l-1][i][j-1],d[l-1][i][j+1]));
                if(v!=0)d[l][i][j]=v+a[i][j];
                if(i==j&&l==1&&i==1)d[l][i][j]--;
                if(l==m)
                    {
                    if(i==j&&i==1)
                        k=d[l][i][j];
                    k=max(k,d[l][i][j]);
                    }
                }
            }
        }
    printf("%d\n",k);
    return 0;
}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By mafia, 13 years ago, In English
I want to create my own contest, but I don't know how to do it. If you know tell me please.

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By mafia, 14 years ago, In English

I believe train.usaco.org is the best web site to prepare yourself to IOI. There is also some contests for example bronze contest, silver contest, gold contest and etc. If bronze contest's problems was easy for you I am sure that you can take at least bronze medal at IOI. Check it maybe it will help you =).

If you need any help you can ask me ibrohim1@bk.ru.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it