Page 4 of 5
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Wed Sep 18, 2013 6:55 pm
by IanSwartz
Hi, getting runtime error on Uva but it runs fine on my pc with correct output from testcases found here...
nevermind, solved!
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Wed Dec 18, 2013 4:51 pm
by B_sayem
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Thu Dec 19, 2013 1:34 am
by brianfry713
It should be case insensitive.
Input:
Output should be:
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Tue Dec 24, 2013 10:54 am
by mobarak.islam
I am getting WA here . Please help me .
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<cctype>
#include<cstdio>
#include<cstring>
int main()
{
char s[1000000];
int init,end;
bool des;
while(gets(s)&& strcmp(s,"DONE"))
{
des=false;
init=0;
end=strlen(s)-1;
while(init<=end)
{
if(!strcmp(s," "))
break;
while(init<=end && (s[init]<65 ||(s[init]>90 && s[init]<97)||s[init]>122))
init++;
while(end>=init && (s[end]<65 ||(s[end]>90 && s[end]<97)||s[end]>122))
end--;
if(s[init]>96)
s[init]-=32;
if(s[end]>96)
s[end]-=32;
if(s[init]!=s[end])
{
des=true;
break;
}
init++;
end--;
while(init<=end && (s[init]<65 ||(s[init]>90 && s[init]<97)||s[init]>122))
init++;
while(end>=init && (s[end]<65 ||(s[end]>90 && s[end]<97)||s[end]>122))
end--;
}
if(des)
printf("Uh oh..\n");
else
printf("You won't be eaten!\n");
memset(s,0,sizeof(s));
}
return 0;
}
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Wed Jan 15, 2014 12:41 am
by brianfry713
PM sent
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Mon Feb 24, 2014 2:12 pm
by terry646623
Why I get wrong answer
Code: Select all
thanks! brianfry713.I got accepted. I finally know that Null is very important for string.
Re: 10945 - Mother Bear WA why? Anyone help me please
Posted: Mon Feb 24, 2014 11:02 pm
by brianfry713
Add this before line 133: compare1[new_length] = compare2[new_length] = '\0';
10945 - Mother bear Compile error
Posted: Wed Aug 06, 2014 2:34 pm
by NAbdulla
Re: 10945 - Mother bear Compile error
Posted: Wed Aug 06, 2014 3:55 pm
by lighted
You can see reason of CE here in My Submissions:
http://uva.onlinejudge.org/index.php?op ... n=13999115
It is because of
strlwr.
I don't think either of those functions are part of the ANSI standard, so you might not have them depending on which compiler you are using.
Maybe Judge's compiler doesn't have it.
You can do your own
strlower
Code: Select all
#include <ctype.h>
char* strlower( char* s )
{
char* p = s;
while (*p = tolower( *p )) p++;
return s;
}
Don't forget to remove your code after getting accepted.

Re: 10945 - Mother bear Compile error
Posted: Wed Aug 06, 2014 5:34 pm
by NAbdulla
Thanks a lot. After using userdefined function for that it is ACCEPTED. Thanks.
Re: 10945 - Mother bear
Posted: Tue Sep 30, 2014 10:57 am
by bgcsaif
Code: Select all
Removed after AC!!!
For other: DON'T USE strrev();
Re: 10945 - Mother bear
Posted: Tue Sep 30, 2014 2:06 pm
by brianfry713
You can see the reason for your CE by clicking "My Submissions".
Don't use strrev()
Re: 10945 - Mother bear
Posted: Sat Oct 04, 2014 6:41 am
by bgcsaif
Thanks. . . . I didn't know using strrev(); cause CE. . . . Just did it manually and it is done!

but feeling upset for this problem I had nearly 9 wrong attempt on UVA!

Re: 10945 - Mother bear
Posted: Sun Oct 26, 2014 1:38 am
by iliketocode
Not too sure why i keep getting WA.... hope someone can help me resolve this
Code: Select all
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX 1000
int main(void){
char palindrome[MAX + 1] = {0};
int len, i, j, alpha;
while(fgets(palindrome, MAX, stdin)){
alpha = 0;
len = strlen(palindrome);
if(palindrome[len - 1] == '\n')
palindrome[len - 1] = '\0';
len = strlen(palindrome);
if(strcmp(palindrome, "DONE") == 0)
break;
for(i = 0; i < len; i++)
if(isalpha(palindrome[i]))
alpha++;
for(i = 0, j = len - 1; i < alpha/2; i++, j--){
if(isspace(palindrome[i]) || ispunct(palindrome[i]))
++i;
if(isspace(palindrome[j]) || ispunct(palindrome[j]))
--j;
if(toupper(palindrome[i]) != toupper(palindrome[j])){
printf("Uh oh..\n");
break;
}
}
if(i == alpha/2)
printf("You won't be eaten!\n");
}
return 0;
}
Re: 10945 - Mother bear
Posted: Sun Oct 26, 2014 9:54 am
by lighted
Try to check input in this thread before posting.
jan_holmes wrote:Try this testcase :
.!?,As.,!?i I!!!,S,,a
My Acc program output : Palindrome.
yours : not palindrome.
Hope it helps...

Input
Acc Output
Don't forget to remove your code after getting accepted.
