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


[closed] Can somebody help me debugging this code?

Hey guys!

I was trying to solve CHEFFA from August long. My thinking was same as others used, using table dp[index][x][y], but my code is not only failing on test cases, but also giving TLE. Similar codes have got a AC, so I am guessing I am at fault in implementation.

I will be really grateful if someone can point out my mistake, so that I can know where I erred. My code link-

asked 18 Aug '17, 19:42

vijju123's gravatar image

5★vijju123 ♦♦
accept rate: 18%

closed 18 Aug '17, 23:15

The question has been closed for the following reason "Duplicate Question" by vijju123 18 Aug '17, 23:15

I checked with many random inputs and all of them is giving correct answers. Can't find the test case where it fails! But what I think is, it's not best practice to use dynamic vectors in recursive functions. You should try to declare them globally and work with them. This dynamic vectors may be one of the reason you're getting TLE.

This is my solution. I hope it helps you in some way.

link text


answered 18 Aug '17, 23:00

sudip_95's gravatar image

accept rate: 10%

Yes, I did got AC after that fact. The problem is WA, not TLE. I can get that, since value of vector is copied, it can not only give TLE but also SIGSEV due to excess memory consumption...

But WA? :( . I appreciate you taking your time out tho! :)

(18 Aug '17, 23:02) vijju123 ♦♦5★

just out of curosity, what was the problem?

(18 Aug '17, 23:08) sudip_954★

Undefined behaviour. This thing is hell to debug, especially if undetected :(

(18 Aug '17, 23:16) vijju123 ♦♦5★

Got the reason for WA.

It was undefined behavior at input size of 1 due to non existence of vector element.


answered 18 Aug '17, 23:15

vijju123's gravatar image

5★vijju123 ♦♦
accept rate: 18%

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 18 Aug '17, 19:42

question was seen: 302 times

last updated: 18 Aug '17, 23:16