Polynomial-Time Algorithm