ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1008. Image Encoding

Help,could you tell me what's the problem of my procedure?
Posted by HeroFay 13 Jul 2003 10:55
#include <stdio.h>

static int map[11][11];
int q[150][2];
int N,i,j;
int x,y,a,b;
int head,tail;

int main()
{
    scanf("%d",&N);

    a = 10,b = 10;
    for(i = 0;i < N;i++)
    {
        scanf("%d%d",&x,&y);
        map[x][y] = 1;
        if(x < a)
        {
            a = x,b = y;
        }
        else if(x == a && y < b)
        {
            a = x,b = y;
        }
        scanf("\n");
    }


    printf("%d %d\n",a,b);
    for(head = 0,tail = head + 1,q[head][0] = a,q[head][1] =
b,map[a][b] = 2;head < tail;head++)
    {
        x = q[head][0];
        y = q[head][1];
        if(map[x + 1][y] == 1)
        {
            map[x + 1][y] = 2;
            q[tail][0] = x + 1;
            q[tail++][1] = y;
            printf("R");
        }
        if(map[x][y + 1] == 1)
        {
            map[x][y + 1] = 2;
            q[tail][0] = x;
            q[tail++][1] = y + 1;
            printf("T");
        }
        if(map[x - 1][y] == 1)
        {
            map[x - 1][y] = 2;
            q[tail][0] = x - 1;
            q[tail++][1] = y;
            printf("L");
        }
        if(map[x][y - 1] == 1)
        {
            map[x][y - 1] = 2;
            q[tail][0] = x;
            q[tail++][1] = y - 1;
            printf("B");
        }
        map[x][y] = 3;

        if(tail - 1 == head)
            printf(".\n");
        else
            printf(",\n");
    }

    return 0;
}