Your name is mine

what is wrong with the code?
http://ww2.codechef.com/viewsolution/2130155

@max0806 >> Consider this test case

johnn johana

Your program says YES but actually it should be NO.
I let it up to you to find the bug. Good Luck!

EDIT:

@milhaus >>

Bad indentation might result from various ways, if the user himself is coding with bad indent or he is using some editor which is not indent compatible with that when pasted here, so it gets distorted. Same happens when I copy a user’s code to test where was it failing. So what I do is as follows. Credits to my professor (the Linux guru).

For indenting a code in vi editor (Linux), open the file in vi or vim, type “gg=G” without quotes, done!

NOTE: You must quit the INSERT mode to type this command, just like you do to save the file. (":wq")

I would rather prefer you find the bug in your own code. As a hint, work out the following example by hand with your code and you should figure out the bug.

W - “elly”

M - “elgamy”

@bugkiller and @ mynameborat thanx a lot ,so foolish of me,i was in need of help of this kind only…i should hv done this in the contest…:frowning:

nevermind. We all are in learning phase. Good Luck for future.

I also recommend you better formatting of your code (unless the formatting changed after you submitted your solution), because it is very illegible. E.g. the indentation of the corresponding braces { and } should be the same. Your code also has one redundant part, you could e.g. check which string is shorter and assign them accordingly to “shorter” and “longer” variables, then you can eliminate the redundant part.

I have edited my answer for a shortcut to indent fast.

What is wrong with this: http://ww2.codechef.com/viewsolution/2147760 . It has been 3 days but I havn’t been able to figure it out.

@yogeshpoddar >> From the first sight: increase the array size by 1 each, and you also need to include string.h header.

Can you tell me what is this?

printf("\n");
for(i=0;i<T;i++)
{
	if(ans[i]==1) printf("YES");
	else printf("NO");
	if(i==T-1) break;
	else
	printf("\n");

}

I think this leads to WA…

@betlista >> Nope, thats fine. See the calculation part for ans[]. Also have a look here http://ideone.com/DzPJwV

My point was, that he prints empty line first and there is no new line character after the last line (but this is not a problem probably)…

I was getting the correct answers earlier for all the cases I tried. I think there is some other kind of error . Though I have incorporated the string.h and increased the array size.

@betlista >> The first empty line won’t matter, 'cause output starts off on a new line anyway. Regarding not printing last line, again no probs. Check the link again and try commenting/uncommenting line #13 and #54. Also, I guess if we print more than 1 newlines in this problem, judge might accept, if the program is written to skip blank spaces. In some problems it is specifically mentioned. Can’t test on here, as “access denied”. If you can, then please check and tell.

@bugkiller >> I have tried the space things while uploading my answer. But every time it showed wrong, while it worked absolutely fine on my machine.

Have you tried submitting again with increased array sizes?

There is no submission button now.

Yes, then wait till it comes back and tell if you still get the same problem. Or if you’re not getting “access denied” page unlike me then you can go to the submit page by tampering the URL of the problem like this http://ww2.codechef.com/problems/submit/NAME2/

It still gives wrong answer. :frowning:

then will have a look on it after dinner. bbl.

//