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

What 's Wrong??
Posted by lol 1 Oct 2007 21:36
#include<stdio.h>
int map[101][101];
int x,y;
int sx,sy;
int now;
int n;
int stack[3][101];
int ps,pe;
int push(int x,int y)
{
    stack[1][ps]=x;
    stack[2][ps]=y;
    ps++;
    return 0;
}

int gen(int x,int y)
{
    int tmp;
    now++;
    if(map[y][x+1]==1)
    {
        printf("R");
        map[y][x+1]=0;
        push(x+1,y);
    }
    if(map[y+1][x]==1)
    {
        printf("T");
        map[y+1][x]=0;
        push(x,y+1);
    }
    if(map[y][x-1]==1)
    {
        printf("L");
        map[y][x-1]=0;
        push(x-1,y);
    }
    if(map[y-1][x]==1)
    {
        printf("B");
        map[y-1][x]=0;
        push(x,y-1);
    }
    if(now<n)
        printf(",\n");
    else
        printf(".\n");


    while(pe!=ps)
    {
        tmp=pe;
        pe++;
        gen(stack[1][tmp],stack[2][tmp]);
    }

    return 0;
}


int main()
{
    int i;
    scanf("%d",&n);
    scanf("%d%d",&sx,&sy);
    for(i=2;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        map[y][x]=1;
    }
    printf("%d %d\n",sx,sy);
    now=0;
    gen(sx,sy);

    return 0;
}