Some other important things
Fast Input/Output
- In C++, for fast input / output, while using cin and cout, use these lines :
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// all your code below this
….
}
- These above lines makes cin, cout work faster. It is advised to add these statements in all your codes.
tip
Also for fast output, don’t use cout << endl. Instead use cout << ‘\n’ for a newline. It works faster.
Avoid common mistakes
You must become familiar with the following :
- Common errors on online judges like TLE, MLE, Runtime error, Compile error and how to get rid of them
- When does overflow occur ? How to prevent overflow ?
- How to compare floating point values, like doubles ? (we can’t simply use == )
You may refer to this great blog, to get familiar with these.
tip
To get rid of type-casting int to long long multiple times for preventing overflow, you may want to write this at the top:
#define int long long
For this to work, also replace int main()
by :
int32_t main()
Session Slides
- The whiteboard slides, used during the introduction session, are available here