Errors you Encounter while Programming !

Revision en4, by iamartyaa, 2021-02-21 18:47:39

_Enjoying the sport of Competitive Programming but some Errors/Exceptions hindering your experience? Well, you landed at the perfect Blog _

Listed Below are some of the most common Error Codes/Exceptions you face while submitting your solutions to online platforms like Codeforces/CodeChef/AtCoder etc.

SIGSEGV :

A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory. Some of the other causes of a segmentation fault are: Using uninitialized pointers, dereference of NULL pointers, accessing memory that the program doesn’t own.

Fix :

  1. Make sure you aren’t using variables that haven’t been initialized. These may be set to 0 on your computer, but aren’t guaranteed to be on the judge.

  2. Check every single occurrence of accessing an array element and see if it could possibly be out of bounds.

  3. Make sure you aren’t declaring too much memory. 64 MB is guaranteed, but having an array of size [10000][10000] will never work.

  4. Make sure you aren’t declaring too much stack memory. Any large arrays should be declared globally, outside of any functions — putting an array of 100000 ints inside a function probably won’t work.

SIGABRT :

A SIGABRT is caused if your program aborted due to a fatal error. This can also be caused if you are using an assert() which fails or an abort().

Fix :

In C++, this is normally due to an assert statement in C++ not returning true, but some STL elements can generate this if they try to store too much memory.

SIGFPE :

A SIGFPE is the easiest runtime error to debug — it is a floating point error. It is virtually always caused by a division by 0, so check any divisions or modulo operations in your code carefully.

NZEC :

NZEC stands for Non-Zero Exit Code. Usually, returning non-zero values from main() will cause this error. It helps telling crash from WA (Wrong Answer) with interpreted languages. Typically this would happen if you omit a** return 0;** from main() in C. For interpreted languages or Java/C++, this could happen if your program threw an exception that was not caught (e.g. Trying to allocate too much memory in a vector).

WA :

Wrong answer means simply that — your program is not printing out the correct answer. You will just have to debug your program very carefully! Make sure your program is conforming exactly to the output format required, and not printing out unnecessary information.

TLE :

The online judge allocates resources like memory and CPU for evaluating every submission. To ensure that your submission does not keep running for an infinite time, the online judge has to stop your submission from running after a particular time period. This time period is actually decided by the problem setter and is given as one of the inputs to the online judge. Once the submission program runs for time period the judge system issues a system kill command to the program execution and assigns TLE result to the submission.

Fix :

The most common reason that you would get a TLE is because your program is too slow. Read the bounds in the input carefully before writing your program, and try to figure out which inputs will cause your program to run the slowest. You will just need to come up with a quicker algorithm.


Did you find the blog helpful? Do upvote to let me know :) Happy Coding, Regards iamartyaa

Tags #dailycoding, #coding, #error, #errors, #exception, #atcoder, #codechef, #codeforces, #fix, #search, #competitive-programming, #competitive-

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English iamartyaa 2021-02-21 18:47:39 24
en3 English iamartyaa 2021-02-21 18:45:48 642 Reverted to en1
en2 English iamartyaa 2021-02-21 18:45:13 642
en1 English iamartyaa 2021-02-21 18:42:13 3723 Initial revision (published)