Skip to content

Latest commit

 

History

History
203 lines (158 loc) · 17.8 KB

File metadata and controls

203 lines (158 loc) · 17.8 KB

tasks timus rank acmp rank

Note on usage

Important! Check LICENSE! All rights reserved, no permission is granted! The code here is protected by default copyright rules: you may view and read it for personal study, but please do not copy or reuse complete solutions directly! It's a matter of ethics. It’s published for learning and reference only, also as a showcase of my approach, not a bundle of copy-paste ready answers.

I only add solutions that I consider highly above average or hard in difficulty or personally interesting, i.e. things that taught me something non-trivial. This is not a solution graveyard. : - )

Highlights

Here are the most, in my opinion, notable solutions:

ACMP

  • 0435 - reachable-state enumeration + interning (dedup) + Chinese remainder theorem + subset sum + NFA → DFA (subset construction) + Miller-Rabin primality test.
    (solution · statement)

  • 0932 - centroid decomposition + combinatorics (counting/aggregation over a tree with centroid splits).
    (solution · statement)

  • 1394 - assignment problem + Hungarian algorithm + augmenting paths + primal-dual potentials.
    (solution · statement)

  • 0866 - st-numbering + graph biconnectivity + ear decomposition.
    (solution · statement)

  • 0981 - boolean expressions theory + functional bases (logic parsing + basis properties).
    (solution · statement)

Yandex CodeRun

Timus

  • 1399 - Capacitated Vehicle Routing Problem (CVRP/VRP) + TSP on subsets (Held–Karp bitmask DP) + greedy heuristics.
    (solution · statement)

  • 2122 - combinatorics + hamming contribution trick + generating functions + NTT under 40961.
    (solution · statement)

  • 2042 - segment tree + lazy range assignment + Manacher on small buffer.
    (solution · statement)

  • 1829 - routing tables + LPM + bitmasks (IPv4 AND mask) + DFS traversal + rule equivalence checking.
    (solution · statement)

  • 1598 - DSA + finite fields + modular arithmetic + fast modular exponentiation + BSGS + crypto break via small parameters.
    (solution · statement)

  • 2196 - computational geometry + point-in-convex-polygon (O(log N)) + point-to-segment distance + Minkowski sum / offset (Steiner formula).
    (solution · statement)

Task index

All tasks
Source ID Lang Solution Statement
ACMP 0011 C++ acmp/0011.cpp link
ACMP 0223 C acmp/0223.c link
ACMP 0306 C++ acmp/0306.cpp link
ACMP 0337 C++ acmp/0337.cpp link
ACMP 0435 C++ acmp/0435.cpp link
ACMP 0441 C++ acmp/0441.cpp link
ACMP 0576 C++ acmp/0576.cpp link
ACMP 0618 C++ acmp/0618.cpp link
ACMP 0652 C++ acmp/0652.cpp link
ACMP 0662 C++ acmp/0662.cpp link
ACMP 0671 C++ acmp/0671.cpp link
ACMP 0861 C++ acmp/0861.cpp link
ACMP 0866 C++ acmp/0866.cpp link
ACMP 0880 C++ acmp/0880.cpp link
ACMP 0884 C++ acmp/0884.cpp link
ACMP 0914 C++ acmp/0914.cpp link
ACMP 0932 C++ acmp/0932.cpp link
ACMP 0937 C++ acmp/0937.cpp link
ACMP 0959 C++ acmp/0959.cpp link
ACMP 0973 C++ acmp/0973.cpp link
ACMP 0981 C++ acmp/0981.cpp link
ACMP 0990 C++ acmp/0990.cpp link
ACMP 1000 C acmp/1000.c link
ACMP 1394 C acmp/1394.c link
ACMP 1690 C++ acmp/1690.cpp link
CodeRun 0005 C coderun/0005.c link
CodeRun 0026 C++ coderun/0026.cpp link
CodeRun 0042 C++ coderun/0042.cpp link
CodeRun 0046 C# coderun/0046.cs link
CodeRun 0047 C++ coderun/0047.cpp link
CodeRun 0049 PHP coderun/0049.php link
CodeRun 0078 C coderun/0078.c link
CodeRun 0113 C++ coderun/0113.cpp link
CodeRun 0115 C++ coderun/0115.cpp link
CodeRun 0117 C++ coderun/0117.cpp link
CodeRun 0153 Python coderun/0153.py link
CodeRun 0156 C++ coderun/0156.cpp link
CodeRun 0157 C++ coderun/0157.cpp link
CodeRun 0162 C++ coderun/0162.cpp link
CodeRun 0219 C++ coderun/0219.cpp link
CodeRun 0222 C++ coderun/0222.cpp link
CodeRun 0243 C++ coderun/0243.cpp link
CodeRun 0266 C++ coderun/0266.cpp link
CodeRun 0270 C++ coderun/0270.cpp link
CodeRun 0347 SQL coderun/0347.sql link
CodeRun 0404 PHP coderun/0404.php link
CodeRun 0417 PHP coderun/0417.php link
CodeRun 0547 C++ coderun/0547.cpp link
CodeRun 0567 C coderun/0567.c link
CodeRun 7271 C++ coderun/7271.cpp link
CodeRun 7507 C++ coderun/7507.cpp link
CodeRun 7513 C++ coderun/7513.cpp link
CodeRun 9012 C++ coderun/9012.cpp link
CodeRun 9013 Python coderun/9013.py link
CodeRun 9098 C coderun/9098.c link
CodeRun 9325 C++ coderun/9325.cpp link
Timus 1041 C++ timus/1041.cpp link
Timus 1092 C timus/1092.c link
Timus 1271 C++ timus/1271.cpp link
Timus 1337 C++ timus/1337.cpp link
Timus 1399 C++ timus/1399.cpp link
Timus 1541 C++ timus/1541.cpp link
Timus 1598 C++ timus/1598.cpp link
Timus 1618 C++ timus/1618.cpp link
Timus 1624 C++ timus/1624.cpp link
Timus 1704 C++ timus/1704.cpp link
Timus 1771 C++ timus/1771.cpp link
Timus 1815 C++ timus/1815.cpp link
Timus 1829 C++ timus/1829.cpp link
Timus 1839 C++ timus/1839.cpp link
Timus 2041 C++ timus/2041.cpp link
Timus 2042 C++ timus/2042.cpp link
Timus 2077 C++ timus/2077.cpp link
Timus 2086 C++ timus/2086.cpp link
Timus 2096 C++ timus/2096.cpp link
Timus 2097 C++ timus/2097.cpp link
Timus 2122 C++ timus/2122.cpp link
Timus 2188 C++ timus/2188.cpp link
Timus 2196 C++ timus/2196.cpp link
Timus 2223 C++ timus/2223.cpp link

Problem sources

As you might have guessed, most of the problems in this repository come from two major Russian competitive programming training platforms:

  • ACMP - it’s a long-running site with a huge archive of problems. Alongside solid classic tasks, there are plenty of quirky and non-standard problems - sometimes with unusual constraints, odd formulations, or obscurity in the sense of being more about decoding the statement and handling edge cases than applying a clean textbook algorithm. The site is maintained by Sergey N. Belyaev (listed as the author/admin in ACMP materials) and is associated with the Krasnoyarsk Krai Palace of Pioneers and Schoolchildren.

  • Yandex CodeRun - it’s Yandex’s developer training platform: an online problem catalog and curated selections to practice programming across multiple tracks (e.g., backend, frontend, mobile, ML/analytics). It also has community features and periodic challenges/events. The platform is operated by Yandex LLC (ООО «Яндекс»).

  • Timus Online Judge - a classic ICPC-flavored problem archive and online judge. It hosts Internet versions of many contests held at Ural Federal University (UrFU) and includes problems from regional ICPC/NEERC-style contests (and related training events). The site is created and administered by students and graduates of UrFU.

Languages

  • C/C++ - my primary languages. I use them at work, I enjoy them, and most competitive programming tasks are a natural fit for this toolset.
  • C# - here mostly out of curiosity. I occasionally poke the .NET ecosystem/infrastructure just because I`m interested.
  • PHP - work-driven: I deal with the PHP ecosystem from the runtime/engine and extensions side (C mostly). We run static analysis on the engine/addon code, triage findings, and do fuzzing. Sometimes I write some PHP to better understand how it behaves in practice.
  • Python - the baseline language. It’s the quickest way to prototype, validate ideas, or write tiny utilities. I use it when I don`t wanna be bothered.

Code style

This repository is mostly competitive-programming style code: consistent, fast to write/read under time pressure, and focused on the algorithm rather than ceremony.

What you’ll see a lot (generally in C/C++ files):

  • A small personal template: #include <bits/stdc++.h>, fast I/O, and a few tiny helpers/aliases.
  • Short, consistent naming: n, m, k, ans, g, dp, dist, etc. The goal is to reduce visual noise. I don`t like long words.
  • Shorthands/macros like rep, sz, all, pb, fi/se, rsr(...) to compress boilerplate (looping, container ops, pair access). This is intentional and comes from a low-level mindset: make common patterns dense and recognizable. I don`t like long expressions.
  • A deliberate trade-off: this style is great for contests and personal notes, but I do not claim macros are best practice for production.

Build & CI

I keep a small CI pipeline that’s intentionally close to my setup. The goal is reproducibility and “works on my machine” parity - if it compiles here, it’ll compile on my box too.

  • Environment: GitHub Actions runs everything inside a debian:bookworm-slim container.
  • C/C++ (LLVM Clang only): every *.cpp is compiled as C++20, every *.c as C11 (-O2 -pipe; C links with -lm). Each file is built standalone and outputs go into build_ci/ - this catches missing headers, accidental dependencies, etc.
  • C# (Mono): compiles every *.cs with mcs (-optimize+) into build_ci_cs/.
  • VB (Mono): compiles every *.vb with vbc (or mono .../vbc.exe fallback) (-optimize+) into build_ci_vb/.
  • Python: syntax/bytecode sanity via pypy3 -m compileall.
  • PHP: lint via php -l.

This is a build/lint sanity check, not a full correctness test. Maybe one day in the future I will decide to organize full-fledged tests.