My CHEFEXQ solution - giving WA

Can any one help me to find mistake in this code ( https://www.codechef.com/viewsolution/16473210 )?
This is giving WA for one test case. In this test case, all the queries are of type 2 (no updates) and n=100000 and q=100000.
My solution uses square decomposition.

Hi @kvsk,
Refer this answer by me for detail : https://discuss.codechef.com/questions/119704/wa-in-chefexq-dec17-long

In short : increase the array size where you are storing counts as maximum 20 digit binary number can be 1048575.

2 Likes

Can someone please provide me test case where my code fails. I am getting WA in most of the cases.

https://www.codechef.com/viewsolution/16573948
@quamruzz44 , @anno
Thanks in advance!!

Hi @vishesh_345,
https://drive.google.com/open?id=1bKqK6zgow5gyiM-yro4x6dlBWxPiaNpD visit here for the test file and correct output file the test file only contains type 2 queries. There are many wrong answers from your code.

Although i have not checked out code completely because of some work but problem is the same as i stated above upto my understanding, feel free to ask if it doesn’t solve your problem.

My solution should give segmentation fault (SIGSEGV) since I am trying to access an array element out of bounds. Why it gave WA instead of SIGSEGV?

@kvsk, what you are saying is correct you are for sure accessing the elements out of bound but in C/C++ arrays the behaviour is undefined and no one knows what will happen. You can always use Valgrind to check these errors or you can use C++ Vectors with .at() for bound checking.

@apptica I remember you was telling me some GCC flag also for such checks. Please mention here.

1 Like