Competitive programming class #1
2026/10/24
- Competitive Programming
- C++
- Operating Systems
Although the title is "Competitive programming class #1", this is in fact a story of our 10th class of the semester.
Today we covered topics related to memory, pointers, and references, and then hosted a small contest among us to put the new knowledge into work.
This class I left the classroom incredibly proud. When we started, most members had little to no experience with C++ or competitive programming. Now, many of them can solve two problems in an actual contest. Seeing that progress firsthand was one of the most rewarding parts of running the club.
Let's see what happened, how I approached teaching the material, and what we learned along the way.
Starting with a question
The class started very concisely with a simple question: Why does this program output?
#include <bits/stdc++.h>
using namespace std;
void add(int a)
{
a = a + 1;
}
int main(void)
{
int a = 0;
add(a);
cout << a;
}
From there, we explored the until yesterday unknown territory of pointers and references.
We saw, with clear, visual explanations, how programming languages assign addresses to variables, what's the heap, what's the stack, what's garbage collection, and more.

I used several analogies to help them parse these complex topics. For example, I used "mailboxes" to represent memory locations, "what's inside the mailbox" to represent what's inside an address, american football pointers to represent "pointers to mailboxes", and even a garbage truck that collects the trash.
My strategy of using analogies proved useful, as my students were able to code a swap function of their own, by completing the following snippet:
#include <bits/stdc++.h>
using namespace std;
void swapPro(int a, int b)
{
}
int main(void)
{
int a = 0, b = 1;
swapPro(a, b);
cout << a << " " << b; // this should print 1 0
}
Finally, we looked at recursion and why it can cause a segmentation fault, finishing with this recursion joke:

Contest and results
The archive of the contest is available here https://codeforces.com/gym/727285
It's a clone of Codeforces Round 952, covering topics from string manipulation, greedy, math, and geometry, with only an hour of solving time. These are the final standings of the contest.

Although the first two places are one of my teammates for the ICPC National Finals and myself, respectively (we used this contest as practice for ourselves), the rest of the club was able to solve two problems.
Considering how most members took a lot of time to solve the first problem and none could solve the second in the last contest, I'm proud to say that we have made a lot of progress.
I'm excited to see what else we can achieve after this class. Teaching and leading this club really makes me happy, makes me feel like I'm contributing to other people.
.