×

# [closed] WA in CHEFHACK

 0 but still i am getting wrong answer ?? please point out my mistake ....?? http://www.codechef.com/viewsolution/1724277/ asked 15 Jan '13, 21:13 15●12●21●24 accept rate: 0% 6.7k●62●119●138

### The question has been closed for the following reason "The question is answered, right answer was accepted" by anton_lunyov 17 Jan '13, 01:57

 0 You should use long long for count. It is mentioned in the quick explanation section of the editorial. I have even made this bold in the editorial now :) But it is not the only issue. Your code is formatted very bad. Try to clean up and utilize it. Otherwise nobody will help you. Also don't post code as questions they are parsed into some ugly creatures by MarkDown. You should post link to your code instead. The best is the link to codechef submission. Links from ideone.com is not convenient to follow. answered 16 Jan '13, 12:49 6.7k●62●119●138 accept rate: 12% still i am getting the wrong answer ... i have gone through my code properly ....but i am not getting why is it WA. http://www.codechef.com/viewsolution/1725495 plz help .....??? (16 Jan '13, 13:59) You should use printf("%lld\n", count). Also this if(mymap.find(a[i][j])!=mymap.end()) is bad since it will cost you TLE on the test where all passwords are prime. I've suggested you another way. Also in your dfs routines it is wrong to check a[i-1][j] without checking that i > 0. In this case you are accessing some wrong cell and anything could happen. But probably in your implementation this does not happen. But it is general suggestion to check the correctness cell before accessing to it. Of course the same is true for other cells. (16 Jan '13, 14:26) 1 Finally I realize your main mistake in your dfs routines you will mark prime numbers as well. You should check in addition to a[i][j]%2!=0 also that a[i][j] is not prime. And IMHO your code is very ugly and you should reiterate the style and logic you are using when writing the code. You have many similar pieces of codes and some not very safe or redundant checks. (16 Jan '13, 14:29) okkk!!! i got what you said . and i have changed the code as suggested by @anton_lunyov in the previous comment . but still the code is not giving answer correct . http://www.codechef.com/viewsolution/1725860 it is passing the test case which i am trying but some corner test cases are missing . there is a minor mistak and i am unable to get it ....... plz suggest ...?? (16 Jan '13, 17:12) You have the silliest bug ever in sieve. Check my edit of your code that finally got AC: http://www.codechef.com/viewsolution/1726408 I have delete just 6 characters from one line from your code above ;) (17 Jan '13, 01:20) thanks for your valuable response ... as a beginner i learnt alot in this problem...:) (17 Jan '13, 01:39) Good. So I closed your question. It will be a good move from your side to mark my answer as accepted so that I will receive at least some award for spending so much time on fixing your bugs. (17 Jan '13, 01:59) showing 5 of 7 show all

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,070
×148
×21

question asked: 15 Jan '13, 21:13

question was seen: 1,036 times

last updated: 17 Jan '13, 01:59