Programs I've coded for Competitive Programming.
Notes for errors made during coding:
- ALWAYS THINK OF DYNAMIC PROGRAMMING BEFORE USING COMBINATORICS.
- Calculate eps value(Don't just guess):
- Eps value can varies depending on round error while performing arithmetic calculation.
- Avoiding divides (if can) & sqrt() in real number processing.
- Can compare (a / b) & (c / d) by comparing (a * d - b * c) to 0.
- Watch out for memset() function when test cases if large.
- Use memset function when we don't have to memset too many times.
- Instead of can reinitializing value in the loop that reads in the input together.
- Implement adjacency list by vector instead of using struct pointer.
- Sorting function requires strictly smaller(or larger) comparison, or else will lead to wrong answer.
- When calculating number of digits of of a number, using log(num) / log(10) + 1 can lead to wrong answer sometimes. Better convert the number to string & use sz(num.to_string())
- A NOVICE'S MISTAKE: declare global variable but mistakenly also declare it in the function -> wrong answer!!