CHEFHACK - Editorial

Can the admins tell what’s wrong with http://www.codechef.com/viewsolution/1703688?

In other note :- The tester solution is not getting complied on gcc. Need to include stdio.h.

How is it coming out to be 2. Can you please explain?

Your code is very long. Delete at least all this annoying debugging printf before asking for help.

1 Like

New id is 1742822. Thanks.

I’m getting WA my solution is this http://www.codechef.com/viewsolution/1742829.

Hi There, your solution did not work on the following test case.

1

6

1034 5036 5076 8099 6543 7853

0 2 4 6 8 10

1 5 7 9 13 15

1034 5036 5076 8099 6543 7853

1034 5036 5076 8099 6543 7853

1034 5036 5076 8099 6543 7853

The answer is 9076. It is giving 5087.

Its just for testing ‘1’ at place (1,1)…
Got my mistake…
its a silly one in function kr1(int,int)…wrote pass[i][j] instead of typ[i]][j]…
damn shit…

Try this test:


The correct answer is 436746489.
While your answer is 458527862.

The test data, http://pastebin.com/raw.php?i=j6UWCAZ5
is too large for me to debug the program, so I am unable to find why is it giving 421211088 instead of correct result. Can you please help.
My solution is http://www.codechef.com/viewsolution/1696242

I have updated the editorial. Please read and follow the SUGGESTION at the beginning of editorial.

I have updated the editorial. Please read and follow the SUGGESTION at the beginning of editorial.

i have checked all the test cases which u have provided in the editorial and it gives right answer.I am unable to figure out the problem. http://www.codechef.com/viewsolution/1744261

That’s great anton_lunyvon. Thanks a lot.

In routines oddserver and evenserver you should check before accessing valid[k][l] (or valid[m][n]) that cell (k,l) (or (m,n)) lies inside the grid. Probably this is the reason.

I habe a problem in my solution http://www.codechef.com/viewsolution/1745646 based on the editorial which seems to be more a compiler/c++ problem then an algorithmic problem.
I got the error “Access violation reading location 0x01A4B7A4” when trying to read from my big prime array. Can anyone help?

Your array for primes is too small. Add one zero to K. Like here:
http://www.codechef.com/viewsolution/1745675

1 Like

@anton_lunyov (valid[i][j] is itself a array which has 1 at (i,j) if i,j lies inside the grid otherwise valid[i][j] contains 0) it is also workin well .please help to sort out this problem ,still unable to fiure out the problem

In evenserver() instead of

 if(!valid[k][l])
     return 0;

you should write

 if(k<0 || k>=n || l<0 || l>=n || !valid[k][l])
     return 0;

where n is the size of the grid that should be defined globally.

The same should be applied to oddserver() but be careful you are using variable n there as y-coordinate of the cell.

If you will have troubles with fixing it you can refer to my edit of your code that got AC:
http://www.codechef.com/viewsolution/1745787

Greatly appreciated, Anton! I should have noticed it by myself!

Please have a look at the following solution :

http://www.codechef.com/viewsolution/1746818

It gave correct results for the test cases mentioned in the editorial here, those in the problem statement and some cases generated by myself. But still it displays ‘Wrong Result’ here.

Please help!