Page 1 of 1

2062 WA!!!

Posted: Sun Jan 11, 2009 9:21 am
by Obaida
Some one plz help me i got WA.

Code: Select all

removed

Re: 2062 WA!!!

Posted: Sun Jan 11, 2009 11:06 am
by newkid
try this input

Code: Select all

abc
end
my program outputs

Code: Select all

<abc> is acceptable.
your program outputs

Code: Select all

<abc> is not acceptable.
hope this helps..

Re: 2062 WA!!!

Posted: Sun Jan 11, 2009 12:18 pm
by Obaida
Thank you. But still Wa!!!!

Code: Select all

removed

Re: 2062 WA!!!

Posted: Mon Jan 12, 2009 2:17 am
by newkid
There are several anomalies/bugs in your code.

first of all, the if condition is wrong and should never be written in the way you wrote..

Code: Select all

if((st[i-1]==st[i-2]&&i>=2)||(st[i-1]==st[i+1]&&i<len-1)){acc = 0;break;}
it should be..

Code: Select all

if((i >= 2 && st[i - 1] == st[i - 2]) || (i < len - 1 && st[i - 1] == st[i + 1]))...
what i want to say is the boundary condition i >= 2 or i < len - 1 must be checked first and then array accessing..

and i think your code will fail in the following input..
bcda

it prints bcda is acceptable but its not..

hope this helps..

Re: 2062 WA!!!

Posted: Mon Jan 12, 2009 6:32 am
by Obaida
Thank you.
I got acc. :(