Tips On Competitive Coding

I know, I’m not an advanced coder, but there are some things that might help you with time reduction and more efficiency on competitions.

  1. Fast I/O
ios_base::sync_with_stdio(false);
cin.tie(NULL);

Put this code in your main function, and it will fasten your cin and cout..

2. Header

#include <bits/stdc++.h>

Many people might know this, but this header file includes most of the stuff you probably need. Also USACO grading computers support this so that’s another time saver.

3. I/O from file

freopen("filename.in", "r", stdin);
freopen("filename.out", "w", stdout);

There are many ways to get input from a file and output to a file, but this is the way I use (I know, I didn’t close it back, but it should be fine)

Published by dz2701

Student Coder, interested in learning new Algorithms and new challenges!

Leave a Reply

Create your own website, free on WordPress.com.Create your own website.
Start free