Salman Adnan

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. Salman spent about eight months on it full time, starting with a university course. This is that work cleaned up: 361 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 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.
361solutions, all compile
8 / 8range-query solutions match brute force
1,000random cases each

Overview

361 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 7 Codeforces rounds, 5 AtCoder contests, and the class contests, labs and problem sets of CS 334 at Habib University. Most of them, 267 of the 361, are written inside one of two sizes of the same contest template; the full one is in the repository too. Another 30 files, written by other people and kept for study, sit apart in their own labelled folder and are not counted.

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 regression script for the bugs a full review turned up: each fixed solution is checked against a brute force written from its problem statement, with sanitizers on.
  • A build script that compiles every file with the flags a judge uses and reports anything that fails.

Results

Verified on 2026-10-26 in a clean gcc:13 container: every file in the repository, the template included, compiles with g++ 13 at -std=gnu++17 -O2, all eight range-query solutions agree with brute force on 1,000 random cases each, and every solution fixed after a line-by-line review passes its own brute-force test under AddressSanitizer. To prove the checks can fail, the minimum query was deliberately broken and it failed on the first case, and the old versions of the fixed solutions fail the same tests.

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.