CustomCC0-1.0#ct-p3-041880
Two-Layer Topological Scheduling
Summary
- •Phase 3 / graph-shortest-path
- •Reasoning-first competitive programming drill
Problem Description
Tasks have precedence and each task is morning or evening. Minimize day count respecting both orders.
How to read this problem in plain language:
- This is a Phase 3 reasoning drill focused on graph-shortest-path.
- Typical lenses to test first: topological-sort, dp, scheduling.
- Constraints reminder: n,m <= 2e5
Mini examples for mental simulation:
1) Boundary example: Should reduce to longest path in DAG.
2) Adversarial example: Many day increments due to type switches.
Lite-mode writing target:
- Write 1~2 observations that shrink the search space.
- Name one final algorithm and state target complexity explicitly.
- Validate with at least 2 edge cases and one hand simulation.
Constraints
- •n,m <= 2e5
Analysis
Key Insight
DP dependencies are predecessor-only. This step should reduce search space or formalize correctness. State why this insight changes your algorithm choice.
topological-sortdpscheduling