Need help with WA #10 If anybody know test cases which broke the program, please, share them. Thanks in advance. UPD: Below is the algorithm I used to solve this problem, but still got WA#10. Please suggest any test case which can break the algorithm. Let's suppose we have two arrays (Collections) named e.g. Left and Right. These collections are empty. So, we iterate through the numbers from 1 to N. If any of the collections contain the current number we do nothing. Otherwise (this is the first occurrence of this number), we put current number into the Left collection and start iterating through his friends: The logic here is almost the same. We check whether the current friend is present in any of the collections. If he's not, we put the friend into the Right collection. For example, how this algorithm works on the input data from the problem statement: 1. Current number is 1. Left and Right are empty, so we put 1 into the Left collection and (it's obvious) put all his friends into the Right collection. So the state after the first step is: Left = {1}; Right = {2, 3} 2. The next number is 2. It's present in the Right, so we skip it. 3. The next number is 3. It's also present in the Right, so we skip it. 4. Current number is 4. Neither Left nor Right contain this number, so we put it into the Left. So the current state became - Left = {1, 4}; Right = {2, 3}. 4.1. We iterate through the friends list of the 4. There are the only number 3, which is already present in the Right, so we do nothing. 5. The next number is 5. Here we have the same situation as on the previous step, so the current state became: Left = {1, 4, 5}; Right = {2, 3} 6. Current number is 6. It's not present in Left and Right, so we put it into the Left and the current state became - Left = {1, 4, 5, 6}; Right = {2, 3}. Now we iterate through the list of friends of the 6. There is the only friend 7, which is not present in Left and Right, so we put 7 into the Right collection. 7. Current number is 7, which is already present in the Right, so we do nothing. And the result is: Left = {1, 4, 5, 6}; Right = {2, 3, 7} And the program output is: 4 1, 4, 5, 6 I tried lots of combinations, but they all work correctly. Edited by author 12.02.2013 00:00 Re: Need help with WA #10 Please, correct me if I'm wrong. As I understand from the problem statement, the input must have data which can easily be converted to the matrix with values in cells: 1 - friendship, 0 - non-friendship. So, the "default" test case can be represented as such matrix: 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 I tried to form the test input data such as it'll break the algorithm above, but still is there... It seems that it's impossible to set friendship in such a way that 7 will be a friend of any other and they both will be putted into the same collection. Also, as I understand, the number of people doesn't matter in the resulting teams. So the answer for the input: 4 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3 0 can be: 1 1 Re: Need help with WA #10 Check if this case will work: 4 2 0 1 4 0 4 0 2 3 0 |