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

×

Need debugging BGQRS code

I have been trying this problem for two days now, and have not been able to understand the problem with my code. It looks perfect to me and even after about 30 submissions I have not been able to get it correct. Someone please help me find any bug.
Problem link : BGQRS
My code link : Ideone Code

Thanks :)

asked 23 Jun '17, 23:28

c0d3h4ck3d's gravatar image

4★c0d3h4ck3d
11918
accept rate: 0%


I believe the error is in handling numbers larger than 10^18 . I ran your code on a test case, and it failed.

Input
1
5 3
1000000000 1 1 1 1
1 1 5 1000000000
1 1 1 1000000000
3 1 5
Your Output
36
Expected Output
63

I verified the output by cross checking with various C++ implementations, and they all yield correct output. I am sure that this case is the one agonizing you here.

link

answered 24 Jun '17, 00:19

vijju123's gravatar image

5★vijju123 ♦
13.1k1730
accept rate: 19%

Thanks vijju123 , the error wasn't in handling large numbers, but silly mistake in update()
I was adding number of twos in left child and number of fives in right child while I had to update both in both the childs. :P
Brain's dead :D

(24 Jun '17, 00:33) c0d3h4ck3d4★

It reminds me when i traumatized 2 days over SPOJ's 'Frequent'. I was getting WA in final cases. And after 2 days, do you know what i got? Instead of declaring tree as "tree[4*n+10]" i allotted it less memory and declared it "tree[2*n+1]" . Correcting it got me an AC.

(24 Jun '17, 00:35) vijju123 ♦5★
1

That AC after days of frustration, is what we long for. :)

(24 Jun '17, 00:40) c0d3h4ck3d4★
toggle preview
Preview

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,496
×126
×9

question asked: 23 Jun '17, 23:28

question was seen: 202 times

last updated: 24 Jun '17, 00:40