C++ Online Judge Tips

I am not new to online judges (OJ), but I am still kind of a newbie. Part of the reason I set up this blog is to keep track of my progress at many things, including solving algorithm programming problems. In particular, this semester I am taking CS 577 taught by Dieter , a great professor and the ACM-ICPC coach of our university (UW-Madison). Dieter is utilizing problems on spoj.com as optional programming problems of the assignments. (See the leaderboard.) In this post I am going to present some nice tricks/tips I use.

A C++ Template

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000000 + 10;
const int INF = 0x3f3f3f3f;

inline int iread() {
  int f = 1, x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return f * x;
}

int main() {
  // your code
  return 0;
}

Last Updated on

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.