Digitalise Agency

competitive-programming

Competitive Programming

Competitive programming is solving algorithm puzzles against a clock: a judge runs your code on hidden tests and it has to be right and fast. Our founder, Salman Adnan, spent about eight months on it full time, starting with a university course. This is that work cleaned up: 398 C++ solutions filed by topic, every one of them compiling, and the data-structure solutions checked against a slow, obviously correct version on thousands of random inputs.

Solo

Solo work by our founder, Salman Adnan. Course solutions are from CS 334 at Habib University.

Segment Tree: the data structure behind the range-query solutions, running for real on sixteen values. It builds from the bottom up, answers a range sum by lighting only the few nodes that cover it, recomputes one path on an update, and parks a range add as lazy tags until a later query pushes them down. Every number on screen is computed live. Drag it to orbit, scroll or pinch to zoom. Open full screen
Terminal output of the verification run: every file compiles and all eight range-query solutions match brute force.
The verification run, verbatim: a clean gcc:13 container compiling every file, then the stress test.
398solutions, all compile
8 / 8range-query solutions match brute force
1,000random cases each

Overview

398 C++ solutions to problems from Codeforces, CSES, AtCoder and CS Academy. Most are practice worked by topic: two pointers, bitmasks, prefix sums, number theory, graphs, dynamic programming and range queries. The rest come from 8 Codeforces rounds, 6 AtCoder contests, and the class contests, labs and problem sets of CS 334 at Habib University. Every solution starts from the same contest template, which is in the repository too.

Key features

  • The CSES Range Queries section solved with the structures it is there to teach: a Fenwick tree, a segment tree, a lazy segment tree for range add, one carrying both an add tag and an assign tag, and one carrying an arithmetic progression.
  • Hotel Queries answered by walking down a max segment tree to the leftmost hotel with enough rooms, in O(log n) rather than binary searching over range queries.
  • A stress harness that feeds each range-query solution random inputs and compares every answer to a brute-force loop. The seed is fixed, so a failure reproduces exactly.
  • A build script that compiles every file with the flags a judge uses and reports anything that fails.

Results

Verified on 2026-10-25 in a clean gcc:13 container: all 398 solutions and the template compile with g++ 13 at -std=gnu++17 -O2, and all eight range-query solutions agree with brute force on 1,000 random cases each. To prove the check can fail, the minimum query was deliberately broken and it failed on the first case. Not verified: whether each solution is accepted by its judge, since no verdicts were kept.

Tech stack

  • C++17 (g++ 13)
  • Segment trees, lazy propagation
  • Fenwick trees
  • Python 3 stress harness

Book a call

Let's talk about what you're building.

Pick a slot below.