Monday, March 2, 2015

ACM 1106. Two Teams / Две команды

Here is a little suggestion. Let us start a wave from any node. That chosen node we will send to the first team, then all of his unmarked neighbors will be sent to the second team, and then the neighbors of all the nodes form the previous to the first team and so on. If we have a forest ( where there are sub graphs not connected to one another) then we should do this for all the sub graphs. Then we need to check whether our result is a valid solution or not. If it is not, then there are no other ways of making the teams. 



No comments:

Post a Comment