Блог пользователя iamartyaa

Автор iamartyaa, история, 4 года назад, По-английски

_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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

Автор iamartyaa, история, 4 года назад, По-английски

Hi, Codeforces!

Cannot understand Codeforces interface? Cannot submit your solution? or How to enter a contest?

Don't worry, here is a guide that will help you answer these questions.

Step 0 : Prerequisites: Determination / Dedication.

Step 1 : Open https://codeforces.net/ & enter (log in) with your Codeforces username.

Step 2 : Select the Contests option from the navigation bar.

Step 3 : Select the contest you want to take part in & then click the Register button. When the contest is about to start at the scheduled time, you will get an option to Enter the arena on the same page.

Step 4 : You will be taken to the Contest Dashboard where you will see all the Problems of the contest arranged difficulty wise with the easiest one at the top.

Step 5 : Select the Problem you want to attempt.

Step 6 : After understanding the problem, Switch to your offline/online IDE ( like VS Code ) and write the code to solve the Problem.

Step 7 : Once you are done writing the code & running it on the given test cases, Now you have to submit the code file.

Step 8 : Go back to the Problem and on the right side of the window you will see a Submit? box. Select the language in which you have written the code & then upload your solution using Choose File option. After doing so click on the Submit button.

Step 9 : Your solution is now queued & Codeforces will check the validity of the solution by running several test cases. If your solution passes all the test cases then you will get the verdict Accepted . You can check the status of your submissions through the My Submissions button on the navigation bar.

Step 10 : Solve as many Problems as you can within the stipulated time limit. You can also view the leaderboard during & after the contest.

Congrats! You have successfully participated in your first Codeforces contest.

You can try the steps by participating in Past Contests .

Friendly Tip : You really can't be good at something if you don't like it. So have fun! Good luck!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +66
  • Проголосовать: не нравится