|
|
back to boardShow all messages Hide all messagesYou asked if "No solution" is impossible. My answer was yes. So I'm saying that such a test doesn't exist. +^^+ Locomotive 8 Mar 2003 16:58 Thanks! it was matter of bad English for such an Iranian Boy... Can you help me a little bit more? which algorithm i should use? DFS and BFS dont help... Brute Force doesn`t seem beauty ;)! Please Help Me Best Aidin_n7@hotmail.com First put every child into the first team. Then while there exists a child who has more than one opponent in his team, just move him to the other team. I don't know how. Could you explain it for me? Thank you very much! Can you give me a code, plz? The idea really works. But did you prove that this algo is correct? (Why will it finish the work in a finite number of steps?) It works because in each step number of edges between the two parts increases and obviously it can't be more than E. This proof incomplete and doesn't shed light to the point. We should add next: if person Q on the left side have >=2 enemy on the left then he don't have more than 1 enemies in persons on the right because in other case he would have >=4 enemies. Edited by author 26.11.2011 08:42 It is clear that if proposed algorithm terminates then we have found a solution. But does it allways terminate? I will try to add my 5 cents by giving a short yet complete proof of termination. Let us first introduce the decreasing measure M. We define M to be equal to the number of edges of the graph on the same(!) side. Algorithm terminates if measure decreases with each iteration of algorithm. Let us consider 3 possible situations: 1) We change side of a child with 3 enemies on his side. Then M decreases by 3. 2a) We change side of a child with 2 enemies on his side and 0 enemies on other side. Then measure decreases by 2. 2b) We change side of a child with 2 enemies on his side and 1 enemy on other side. Then M decreases by 2 and increases by 1. 3) If child has only one enemy on his side, then we do nothing. According to described cases M will decrease after each iteration. Hence, algorithm terminates. Hope this helps :) Edited by author 27.03.2006 01:16 |
|
|