445 - Marvelous Mazes
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 445 - Marvelous Mazes - Wrong answer
Input 10T output should be T
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 14
- Joined: Tue Sep 24, 2013 4:35 pm
uva 445
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: uva 445
Input:AC output:
Code: Select all
1111111111111111111111111111111111111111X
Code: Select all
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Check input and AC output for thousands of problems on uDebug!
Re: 445 - Marvelous Mazes - Wrong answer
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
I spent 2 hours to find my first bug and second bug from above java code.
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
I searched threads about this problem and saw this one
http://acm.uva.es/board/viewtopic.php?f ... d4#p214947
I checked that java solution to find my bug and obtained new bug from that wrong solution.brianfry713 wrote:You're only printing 5 T's, there should be 6 T's.
https://ideone.com/X2DXd1


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

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