Stage 1 · Lesson 6 of 8
STL algorithms you will use weekly
The standard library already has functions for most small jobs. unique after sort removes duplicates. accumulate sums a range, max_element finds the largest value, reverse flips a range and iota fills 0, 1, 2 and so on.
next_permutation walks through every ordering, which is how you small inputs. Each one replaces a loop you could get wrong at minute 90 of a contest, and each is tested and fast. Read about them on cppreference, a reference site for C++, and use them until they are automatic.
Common trapcalling accumulate with 0 as the starting value, which sums in int and overflows on large inputs, where 0LL sums in long long.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CourseFreeLearnCpp.com
LearnCpp.com · Beginner
Free and thorough: read the chapters on vectors, references, lambdas and the standard library if C++ is new to you
- BookFreeCompetitive Programmer's Handbook
Antti Laaksonen · Beginner
Chapter 1 covers C++ for contests, input and output and working with numbers; Chapter 2 covers complexity
Practise
Keep handy
Also worth your time
A clear walk through time and space complexity, the language you need to read constraints
- USACO GuideGo deeper
The General section has practical pages on choosing a language, fast input and output and debugging