FAST IO in C++

Can somebody please give me some good source to study Fast IO in C++. By far all the answers to this question seem to be really vague

ios_base::sync_with_stdio(false);
cin.tie(NULL);

This should be enough.

4 Likes

Okay thanks a lot

I am still getting a TLE. My algo has O(nlogn) compexity for n<=10^6.

Some things you can try -

  1. Replace endl with β€œ\n”.
  2. arrays instead of vectors.
  3. avoiding sorting on structs.
2 Likes

Thanks that helped me in some test cases

Any more suggestions. My code is still giving a TLE

If you have tried fast io and also \n and still getting TLE then now it’s time to change your algorithm :smiley:

Thanks a lot guys. Actually my algorithm was not completely optimized. After just some modifications it worked.

2 Likes