445 - Marvelous Mazes

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 445 - Marvelous Mazes - Wrong answer

Post by brianfry713 » Thu Aug 08, 2013 11:10 pm

Input 10T output should be T
Check input and AC output for thousands of problems on uDebug!

walking_hell
New poster
Posts: 14
Joined: Tue Sep 24, 2013 4:35 pm

uva 445

Post by walking_hell » Thu Oct 03, 2013 12:22 am

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;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: uva 445

Post by brianfry713 » Thu Oct 03, 2013 10:49 pm

Input:

Code: Select all

1111111111111111111111111111111111111111X
AC output:

Code: Select all

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Check input and AC output for thousands of problems on uDebug!

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 445 - Marvelous Mazes - Wrong answer

Post by lighted » Thu Jul 24, 2014 6:58 pm

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
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 4 (400-499)”