I submit the same solution to spoj and it gets acepted. here it does not.
Same thing is happening with various number of solutions, here and on hackerblocks
Solution not being accepted
Hi
Please paste your link of code
some little difference in questions may be in terms of constraints or output
I guess their is some issue in portal.
in java test case.
Let me check i’ll get back to you.
Please check the test cases, his code is correct and is giving correct ans on SPOJ but not on hacker blocks
Similar is the case with this code
https://ide.codingblocks.com/s/72974
Hy @ksinghparth
I reviewed your code. The problem with your code is your code doesn’t work for test cases like:
1
64 30
For test cases like these your output just overflows the given limit. You need to rectify the combinatorical logic you are applying. I made a solution in java and it worked, so just fight a bit to check where you are going wrong. Obviously your current logic is current just the thing is it reached the limit of overflow easily and thats why you are getting wrong answer. Try to decrease the computations using proper binomial tricks.
@tusharsk I also recrified the test cases at the backend of hackerblocks. The cases are 100% perfect given the constraints of the problem. The cases on spoj are weak. I have mentioned a case above that works fine with cpp solution and is given perfect answer. I want to request you to try some corner cases with the solution of a student, it’s not necessary that if a problem is from spoj or codechef then they have all the cases perfect and there is issue with hackerblocks. The problem setter analyzed some corner cases that were not in spoj and added them here. Yes there are times when some cases are not correct at hackerblocks backend and i appreciate your effort to point out that but i would like to request that first analyze the students solution first because analyzing the test case at backend if they ate correct or not is a hectic task and should be done only in extreme cases. I hope you understand.
Thanks and Regards
Sanket Singh
@Sanket-Singh-1962326997353458
Yeah in other post ( Getting all test cases wrong except one ) i observed the wrong ans for these test case and that is why i have mentioned to re check the backend before i saw his code properly.
Yes there can be errors in any of the platforms hacker blocks or SPOJ
I think there is Error in both the portals.
Test cases in spoj are weak but test case in hacker block is also wrong. The test cases are NOT 100% CORRECT in hacker blocks.
Spoj has a missing test case that you have mentioned.
The case that you have mentioned does not give the right answer, you are looking the wrong answer. the correct answer is https://www.calculator.net/permutation-and-combination-calculator.html?cnv=63&crv=29&x=89&y=32 See this link or google the value of c(63,29)
I would like to request you to at-least first find correct answer of the test case before putting a test case. Yes at times there are problems on every portal.
The problem setter analyzed a corner case but didn’t calculated the correct answer. I would request you if you add any new test cases, check it’s the credibility of test case, and verify it before adding it. I hope you understand it.
test case
1
64 30
correct answer: 759,510,004,936,100,355 (inside 64 bit number )
Hacker blocks ans: 310981744965266872
Spoj does not include this test case.
Hit like if you get it!
Cheers!
Thanks and Regards
Tushar Kumar
You are code has a problem of overflow, use big integer class in java then code it.
Hit like if you get it!
Cheers!
Hy @tusharsk
Thanks for pointing the exact computation overflow, I have already updated all the test cases by considering the BigInteger class. Although the updated case has numbers with the range more than 10^25. But the test cases are now with exact values. C++ students may now find solving this problem directly cumbersome, so for any more threads that comes for the Marbles problem just say them that range of output is huge because C++ student cant directly applies BigInteger sort of thing using STL. I also had a word with the problem setter regarding why he didn’t put the exact case and instead just put the values compatible with C++ solution, then he mentioned the same issue. From now onwards let’s just maintain a doc with a list of problems where you find test cases ambiguous. Also, 99% problems for C++ Launchpad now has editorial and updated test cases and from next month we will work on the competitive course revamp process. Till then let’s just catch up on a document with all the requirements listed.
Thanks And Regards
Sanket Singh
Hi @Sanket-Singh-1962326997353458
Just saw the test cases are updated.
Couldn’t understand you completely but sure will soon definitely catch up on document with all the requirements listed.
Thanks!
Cheers!
The cases for CPP are still not accepting. Given the constraints, the test cases clearly flow out of the range. Answer accepts on SPOJ. But I think problem setters at Hacker blocks have a habit to waste precious time of students by going against the constraints mentioned in the problem itself. For eg: it is mentioned that ans will be in limits of signed long int. But the constraints flow out. Have a stern look at this.
pathetic! @Sanket-Singh-1962326997353458
My sol: https://ide.codingblocks.com/s/73192
have used most time and space efficient method for calculating binomial coefficient along with long long (which is 64 bit).
Hope this is rectified asap.
Hy @Sanyam-Dhawan-1683301181765225
Thanks for posting your concern to this thread, because i was expecting anyone who will be posting his/her in this thread will read all the above replies. I have clearly stated above that test cases are updated and checked twice. The test cases on spoj are too weak. But as @tusharsk already mentioned that for the test case
1
64 30
The answer is larger than 7 * 10^18. So for cases much larger than 64 30 the result will be much larger than this which will not fit in the normal range of long long int. That’s why for students of java we suggested to use BigInteger and i also mentioned that C++ student will face difficulty in handling this long cases because there is nothing like BigInteger in C++, you have to do this using normal arrays. Just read the constraints limit on spoj and hackerblocks as well and just try to calculate for some testcase that how big result u r getting and if it will fit in the long long int range. Problem setters or big known platforms also make a mistake. As per the request of tushar i updated the test cases within 1 Hour. If you know how to calculate large factorials and how manage large numbers using arrays you will find this problem easy.
I hope you understand, sorry if I said something wrong in the above text.
Thanks and regards
Sanket Singh
@Sanyam-Dhawan-1683301181765225
If your doubt is cleared please mark it resolve in your online ask section.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.