What could go wrong Compilation
Hi, folks!
Even after a lot of practice, we still make mucho Silly mistakes. By mistakes, I mean, we ourselves realise them - we shouldn’t have done that. No probs, I’ve got you covered. Here are a few places where we often make mistakes and sometimes blame other elements.
Alright! let’s start.
Newline: You forget - you lose
The output format is something one should really care about. Print on a new line, Print two space-separated Integers and so on. Most of the times, people (at least me) get WA for not printing newline character for each test case. My two codes, WA and AC, are exactly the same, except for the statement to print newline in the latter. Imagine getting 10 minutes of Penalty for this.
Declare int instead of long
This is pretty much a common mistake everyone does. Times when we are supposed to calculate the Cumulative Sum of Sequence or work with bits, we often forget to use long or long long. One might want to write Comments in their template to use long long xD. Common mistakes most of us did and continue to do:
-
1 << i;
instead of1LL << i;
-
int sum = 0;
instead oflong long sum = 0;
(You might want to add others)
Annoying Runtime error
Every time you get a Runtime error, the reason could be one (or many) of these:
- No base case in Recursion - Segmentation Fault (Core dumped)
- Declare an array of {10}^9 elements - Segmentation Fault
- Access invalid memory location - Index out of bound (Java), IndexError (Python) and probably Segmentation Fault (C and CPP).
- Run without providing Custom Input - NZEC.
Modular Arithmetic to Avoid Overflow
Since the answer could be very large, print it modulo 10^9 + 7
Even after noting this, some of us forget it while coding. Some of us are not aware of the steps in calculating it. Instead of me giving tips on this, I would like to attach an existing topic by @galencolin, easy to understand.
Compilation Error (bruh! seriously?)
Who among us confidently submits codes without testing?
For this, I don’t have any tips because readers already know what to do.
Overlook Constraints
The sum of N over all test cases doesn’t exceed 10^6
At least some problems have very small constraints - A Naive solution for problems like this or a slight optimal solution for problems like this will easily win.
Ignore Hard Questions?
Some of us research on some or other topics while we learn. Imagine the hardest problem in a contest is well known to you Like I knew the concept for this problem. It was the hardest problem in October Lunchtime - Division 2 (based on the number of successful submissions). If I had ignored that problem, I would have secured a worse rank. One should read all the problems, at least after the contest is over.
Pre Calculation - keeps TLE away
Who would expect TLE for not storing inverses of 10^6 Integers?
This Problem made me understand the importance of Optimisation. Just because I didn’t Pre-Calculate Inverses of about 10^6 Integers, I faced TLE. Note that One can make use of Memory to avoid TLE .
Have any other problems? You can share them here.