Image Not Found Log In Sign Up

Defeating A Problem

Even after knowing a language concept’s and syntax, we find it difficult to submit questions online. Here are some guidelines every beginner must see before jumping into the world of competitive coding.

Each problem is divided into the following sections where each section provide important information about the problem.

Description

This section provides the baisc information about the problem and explains WHAT you need to do in the problem. Read this section carefully as basic details of the problem is provided under this section.

Input-Output Format

Input format specifies that how our judge will provide the input to the code that you have submitted. It specifies in which order you need to take the input for different variables. Output format specifies that what you need to print and in which order you need to print.

There are some basic mistakes that is made by most of the beginners while taking the input or printing the output. Consider a problem in which a user needs to take a number as input and print it's factorial as output.

Following are the two ways of taking the input for this problem.

Wrong way Correct way
printf("Enter the number :");
scanf("%d", &num);
scanf("%d", &num);
Similarly following are the two ways of printing the output for this problem.

Wrong way Correct way
printf("Factorial of the given number is %d\n", ans); printf("%d\n", ans);
Remember anything you print extra, even your answer is correct, that is not specified in the output section will directly result to WRONG ANSWER.

Other important thing is that you need to print the output in specified format. Consider there are multiple test cases and for each test case problem specifies to print the output in new line than

Wrong way Correct way
1 2 6 24 1
2
6
24

Constraints

This section specifies the range of variables that will be provided during input. These constraints help you to decide that what should be the data type of the variables or the what should be the size of array that you are going to use in your programs. You may also analyze by looking at the constraints that whether the complexity of your code will pass the given time or memory limit as specified in the problem.

Time-Memory Limit

This section specifies that maximum time and memory limit that will be provided to your solution. Your solution must run in the given limits or else will result into some kind of error as explained below.

After going through the above sections of the problem, now it is your turn to think and code the solution. After submitting your solution, you will see one of the following results.

Accepted

This means that your code ran perfectly on our test cases within given time and memory limit and output of your code matched perfectly with our judge's output without any error.

Wrong Answer

This means that the output given by your program did not match our judge's output for the given input (or did not fulfill the conditions in case multiple solutions were possible). This is the most frequently occurring bug that you will face and getting rid of it can be a pain.

Compilation Error

This error occurs when there is syntax error in your code.

Time Limit Exceeded

This means that your code is taking more time to run than the time provided by the problem setter. Note :- A loop of 108 instructions takes approximately 1 sec to run.

Memory Limit Exceeded

This means that you code is taking more memory to run than the default memory size that is allocated to a program. You need not bother unless you are using insanely large amount of memory.

Note :- Try to keep the size of array atmost 107.

Run Time Error / Segmentation Fault

There can be many types of Runtime Exceptions. You cannot know anything more specific. Note that some errors could lead onto other errors, so even if you are getting one particular message, you should check each one separately. Following are the some of the reasons that why you get this error.

Internal Error

This error occurs when our judge fails to evaluate your code correctly. If you face this error than try submitting your solution again. If you keep on facing this error regularly than contact the site administrator and report this error.