Graph Theory37 sections · 1633 units
Open in Course

Problem - Cat and Mouse (Part 7)

(Time and space cost)

The time complexity is O(n2E)O(n^2 \cdot E) where EE is the number of edges. You visit each state multiple times while propagating win/loss information.

The space complexity is O(n2)O(n^2) for storing the state graph and auxiliary arrays like the degree array and win/loss markers. This is acceptable for n50n \leq 50 as specified in the problem constraints. Larger graphs would need different approaches.