I need to clarify some doubts:
1) As long as there are no vertical cycles in the graph, ie: node A is not the ancestor of itself, and there is a valid male/female assignment, then the graph is sexy.
2) A node can "mate" with any other node, even it's own descendent (ie: A is the parent of B, B is the parent of C, and A can "mate" with C to produce D)
3) A node can have either 0, 1 or 2 parents, no more.
I know only Per, Adrian and Joey has solved this question, so I'm hoping one of them will be nice and help me answer my queries as well as test the following test data

input:
Code: Select all
5 6
1 3
2 3
1 4
2 4
1 5
2 5
3 3
1 2
2 3
3 1
8 8
1 5
2 5
2 6
3 6
3 7
4 7
2 8
4 8
7 6
1 5
2 5
2 6
3 6
3 7
4 7
8 9
4 3
3 1
3 2
4 5
4 6
3 7
8 1
8 2
8 5
13 13
5 6
1 6
1 2
2 3
3 4
2 7
3 9
9 13
10 13
10 12
8 10
8 11
6 8
13 14
5 6
1 6
1 2
2 3
3 4
2 7
3 9
9 13
10 13
10 12
8 10
8 11
6 8
13 9
9 13
1 3
1 4
2 4
3 9
3 5
4 5
4 7
5 6
6 8
7 8
8 9
3 6
5 7
9 13
1 3
1 4
2 4
3 9
3 5
4 5
4 7
5 6
6 8
7 8
8 9
3 6
5 8
Code: Select all
Graph number 1 is sexy
Graph number 2 is not sexy
Graph number 3 is not sexy
Graph number 4 is sexy
Graph number 5 is sexy
Graph number 6 is sexy
Graph number 7 is not sexy
Graph number 8 is not sexy
Graph number 9 is not sexy