Cod sursa(job #637258)

Utilizator VmanDuta Vlad Vman Data 20 noiembrie 2011 13:29:21
Problema DreptPal Scor 0
Compilator cpp Status done
Runda .com 2011 Marime 0.7 kb
#include <cstdio>

#define Nmax 1001
#define Mmax 1001

int N, M, i, j;
int A[Nmax][Mmax], L[Nmax][Nmax];

int palind(int x, int y)
{
    int st, dr;

    st = dr = y;
    while (st>0 && dr<M)
    {
          --st; ++dr;
          if (A[x][st] != A[y][st]) break;
    }
    
    return dr-st-1;
}

int main()
{
    freopen("dreptpal.in","r",stdin);
    freopen("dreptpal.out","w",stdout);
    
    scanf("%d %d", &N, &M);
    for (i=0; i<N; ++i)
        for (j=0; j<M; ++j)
            scanf("%d", &A[i][j]);
            
    for (i=0; i<M; ++i)
        {
              for (j=0; j<N; ++j)
                  L[i][j] = palind(i, j);
              
        }
    
    return 0;
}