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


[closed] Where have I made mistake?

Problem code
My solution

My code cannot pass the test cases even.

asked 23 Sep '15, 11:42

dragonemperor's gravatar image

accept rate: 10%

closed 27 Sep '15, 13:29

The question has been closed for the following reason "The question is answered, right answer was accepted" by dragonemperor 27 Sep '15, 13:29

@dragonemperor You need to debug the code yourself. Not only will this help you develop as a programmer, but in any scenario (job, research, contests), you will face situations where your code doesn't work.

In case you need to generate test cases where your code is failing, I can suggest a pattern:

1) Find the test case where your code is failing.

2) Run the code with a debugger. Use break-points in your IDE to jump to specific points of code.

3) Once the issue is found and the error fixed, submit.

4) If unsuccessful, find a new test case and go back to step 1.

If you can't think of any more test cases, you can generate random tests and check using multiple solvers, as shown here. Since you are coding with C++, I would suggest using Visual Studio as your IDE.


answered 23 Sep '15, 22:54

gkcs's gravatar image

accept rate: 9%

Thank you bro. Your advice worked. I found some errors and I fixed them. I had to change the entire code. I created a test input file, solved using bruteforce and compared with the output of the original code. They are same. So I concluded the code is correct. But when I am submitting, I am getting SIGSEGV. Can you give some guidelines on how to fix that? I tried putting assert statements to my code and found no error, no array index out of bound etc. What other steps can I follow?

(24 Sep '15, 12:44) dragonemperor3★

One possibility is that your local processor has enough memory to spare while the SPOJ processor doesn't. Is there a scenario where your program takes up too much memory.

The other possibility is that an edge case is being missed, but the assert statements should have caught that...

(24 Sep '15, 22:17) gkcs4★

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: 23 Sep '15, 11:42

question was seen: 750 times

last updated: 27 Sep '15, 13:29