The time complexity is where is the number of edges. You visit each state multiple times while propagating win/loss information.
The space complexity is for storing the state graph and auxiliary arrays like the degree array and win/loss markers. This is acceptable for as specified in the problem constraints. Larger graphs would need different approaches.