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: 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 work by Salman Adnan. Course solutions are from CS 334 at Habib University.
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.