Page 7 of 7

Re: 445 - Marvelous Mazes - Wrong answer

Posted: Thu Aug 08, 2013 11:10 pm
by brianfry713
Input 10T output should be T

uva 445

Posted: Thu Oct 03, 2013 12:22 am
by walking_hell
thanks for the previous solutions...i failed to catch my bug in this problem..so i need your help again..

Code: Select all

#include<stdio.h>
#include<string.h>
int rev(int x)
{
    if(x<10)
    return x;
    int mod,sum=0;
    while(x!=0)
    {
        sum=sum+x%10;
        x=x/10;



    }
    return sum;


}


int main()
{
    int numb,count,len,countund;
    char arr[10000];
    while(gets(arr))
    {
        len=strlen(arr);
        for(count=0;count<len;count++)
        {
            if(arr[count]>='0' && arr[count]<='9')
            {
                sscanf(&arr[count],"%d",&numb);
                numb=rev(numb);
                label:

                while(arr[count+1]>='0' && arr[count+1]<='9')
                {
                    count=count+1;


                }

            }
            else if(arr[count]=='!')
            printf("\n");

            else
            {
               if(arr[count]=='b')
               arr[count]=' ';
               for(countund=0;countund<numb;countund++)
                printf("%c",arr[count]);



            }


        }

        printf("\n");


    }

    return 0;
}

Re: uva 445

Posted: Thu Oct 03, 2013 10:49 pm
by brianfry713
Input:

Code: Select all

1111111111111111111111111111111111111111X
AC output:

Code: Select all

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Re: 445 - Marvelous Mazes - Wrong answer

Posted: Thu Jul 24, 2014 6:58 pm
by lighted
I was getting WA (i found my bug at the end).

I searched threads about this problem and saw this one
http://acm.uva.es/board/viewtopic.php?f ... d4#p214947
brianfry713 wrote:You're only printing 5 T's, there should be 6 T's.
https://ideone.com/X2DXd1
I checked that java solution to find my bug and obtained new bug from that wrong solution. :lol: :evil:

I spent 2 hours to find my first bug and second bug from above java code. :evil:

1th bug was reading input in wrong way
2nd bug was printing asteriks only one time. But correct way is to print it as many times as digits before asteriks comes.

I post here so that others will be aware of that bug