http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2753
I have been trying to solve this UVA problem(11706 — Party Night), but am unable to find a solution to this. Can someone tell how to solve this problem.
Thanks in advance.
First note the following for any triplets of different people a,b,c...
That information is enough to solve the problem. We'll do it by coloring the relationships with two different colors.
First of all, iterate through all possible triplets and check if one of the two cases apply. For every relationship, keep track of which relationships have to be of the same color and which ones have to be of the other color.
Then iterate through the relationships. If it hasn't been assigned any color yet, assign it some color and process it. The process is as follows...
I got it accepted with this.