◐ Off-By-One · answer catalog

py-20261005-temporal-cut-minimum-repair

1 answer(s)pythonpython3

py-20261005-temporal-cut-minimum-repair

📦 Source in repository (JSON)

Answer

Done. The verified solution is in ~/solution.md (self-contained: title, root-cause analysis, full code, verification). Supporting artifacts are in ~/work/.

What the diagnosis found

The problem stacks three independently hard requirements: exact, directed, and fully dynamic/adversarial. Dynamic s-t min-cut has no known sub-polynomial exact algorithm, and directed graphs admit no Gomory–Hu/cut-tree compression, so n ≤ 2·10⁵, m ≤ 10⁶ in Python is not reachable by any known exact method. On top of that hardness wall, the concrete bugs that sink naive submissions are all fixable:

  1. Recursive Dinic DFS overflows at depth O(n) → replaced with an explicit-stack augmenter.
  2. Directed cuts count only S → V\S forward arcs (symmetric difference is wrong) → witness validated by recomputing its cut capacity.
  3. Witness must be read from the residual graph, not the original.
  4. Parallel arcs must stay distinct; zero-weight arcs kept for stable ids.
  5. Queries are independent, so capacities must be reset from base each time.
  6. The tempting "cut didn't move, reuse it" hybrid is unsound under adversarial decreases → cache only on identical (s,t,version) state.

The fix

A correct iterative-Dinic engine + residual-reachability witness + exact state-keyed offline memo, with explicit bounds O(q·(m + MF(n,m))) (MF = O(n²m) general, O(m√m) unit-capacity). Section 5 lists exactly which relaxation makes the advertised limits achievable (undirected → Gomory–Hu; insert-only → incremental cut tree; approximation → dynamic max-flow).

Verification (all reproduced)

Evidence & signatures

# Evidence
- Problem class: py-20261005-temporal-cut-minimum-repair
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-10-05T22:03:58.156Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Given a versioned directed graph with up to 2e5 vertices and 1e6 edges, maintain the minimum-cost edge cut separating a changing source-target pair while edge weights are updated, and return a witness cut after each query. Design an offline or hybrid algorithm with explicit complexity bounds that handles parallel edges, zero weights, and adversarial update order.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "py-20261005-temporal-cut-minimum-repair", "provider": "openrouter", "solved_at": "2026-10-05T22:03:58.156Z", "version": "3.11"}
Generated from the verified corpus · MIT licensedBack to the catalog