You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] WA in CHEFHACK

but still i am getting wrong answer ?? please point out my mistake ....??
http://www.codechef.com/viewsolution/1724277/

asked 15 Jan '13, 21:13

vivek07672's gravatar image

2★vivek07672
15122124
accept rate: 0%

closed 17 Jan '13, 01:57

anton_lunyov's gravatar image

6★anton_lunyov ♦
6.7k62119138

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


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.

link

answered 16 Jan '13, 12:49

anton_lunyov's gravatar image

6★anton_lunyov ♦
6.7k62119138
accept rate: 12%

edited 16 Jan '13, 13:08

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) vivek076722★

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) anton_lunyov ♦6★
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) anton_lunyov ♦6★

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) vivek076722★

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) anton_lunyov ♦6★

thanks for your valuable response ... as a beginner i learnt alot in this problem...:)

(17 Jan '13, 01:39) vivek076722★

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) anton_lunyov ♦6★
showing 5 of 7 show all

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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