Contest basics

How online judges work, how to read input fast and judge speed from the limits, and the STL tools that most solutions use.

About 4 hours of study

Learning objectives

Lessons

  1. 1

    Contests, judges and time limits

    How an online judge checks your program, the verdicts it gives, fast input in C++, and how to tell from n whether an idea is fast enough.

  2. 2

    The STL toolbox for contests

    The handful of STL tools contestants use all the time: sort, vector of pairs, set, map and lower_bound.

Module practice

Module quiz

1. A judge runs your program on a test and the output differs from the expected one. What is the verdict?
2. About how many simple operations fit in one second on a judge?
3. n is 5,000. Which complexity is the largest that still runs in time?
4. Which line makes cin and cout faster on large inputs?
5. You need the number of different values in a vector. Which is the simplest tool?
6. lower_bound(a.begin(), a.end(), x) returns a.end(). What does that mean?

Array techniques ›