Improving Man-Optimal Stable Matchings by Minimum Change of Preference Lists †

In the stable marriage problem, any instance admits the so-called man-optimal stable matching, in which every man is assigned the best possible partner. However, there are instances for which all men receive low-ranked partners even in the man-optimal stable matching. In this paper we consider the problem of improving the man-optimal stable matching by changing only one man’s preference list. We show that the optimization variant and the decision variant of this problem can be solved in time O(n3) and O(n2), respectively, where n is the number of men (women) in an input. We further extend the problem so that we are allowed to change k men’s preference lists. We show that the problem is W[1]-hard with respect to the parameter k and give O(n2k+1)-time and O(nk+1)-time exact algorithms for the optimization and decision variants, respectively. Finally, we show that the problems become easy when k = n; we give O(n2.5 log n)-time and O(n2)-time algorithms for the optimization and decision variants, respectively.


Introduction
An instance of the stable marriage problem [1] consists of the same number n of men and women, and each person's preference list.In a preference list, each person ranks all the members of the opposite sex in a strict order.A matching is a set of n disjoint man-woman pairs in which each person appears exactly once.A blocking pair for a matching M is a man-woman pair each of whom prefers the other to his/her partner in M .A matching is stable if it contains no blocking pair.
It is known that there exists at least one stable matching in any instance, and one can be found by the Gale-Shapley algorithm (GS) in O(n 2 ) time [1,2].The stable matching found by GS is called the man-optimal stable matching that has an extreme property that every man is assigned the best possible partner among all the stable matchings.In applications for asymmetric settings, such as assigning residents to hospitals or students to schools, it is common to formulate the problem by setting residents or students to the men's side, so that those people can receive benefit.Nevertheless, there are instances for which all (or almost all) men are assigned low-ranked partners even in the man-optimal stable matching, (e.g., a worst case instance for GS given in Figure 1, which originates from [2]).For such instances, the merit of using the man-optimal mechanism cannot be sufficiently exploited.
Figure 1.Worst case example for the Gale-Shapley algorithm for n = 5.Partners in the man-optimal stable matching are underlined.Each preference list is ordered from left to right in increasing order of the rank, i.e., the leftmost person is the most preferable and the rightmost person is the least preferable.To overcome this drawback, we consider the problem of improving the man-optimal stable matching by allowing small changes in preference lists.In this paper we first allow only one man's preference list to be changed, and consider optimization and decision variants.In the optimization variant, we are asked to find a man and a way of changing his list that cause the maximum improvement.In the decision variant, we ask if we can obtain a positive improvement.For both problems, we impose a restriction that no man should be assigned a worse partner than the man-optimal partner in the original instance.We show that these problems can be solved in time O(n 3 ) and O(n 2 ), respectively.We then extend the problem so that we are allowed to change k men's preference lists.We show that the optimization variant is W [1]-hard with respect to the parameter k.We also give O(n 2k+1 )-time and O(n k+1 )-time exact algorithms for the optimization and decision variants, respectively.Finally, we show that the problems become easy when k = n, i.e., we are allowed to change the preference lists of any number of men.We give O(n 2.5 log n)-time and O(n 2 )-time algorithms for the optimization and decision variants, respectively.
Our problem can also be viewed as an issue of coalition strategy by men.Knowing all the preference lists, men are trying to maximize their total profit by submitting falsified preference lists, while bounding the number of such liars and guaranteeing that no one becomes worse off.Results of this paper show the computational complexities of obtaining an optimal strategy depending on the number k of liars.Strategic issue in the stable marriage problem is an extensively studied topic (see [3] for example).

Problem Definitions
Let I be an instance of the stable marriage problem.In this paper, we consider only complete preference lists with no ties.The rank of a woman w in man m's preference list, denoted r m (w), is one plus the number of women that precede w in m's list.For a matching M and a person p, let M (p) be p's partner in M .The score of m in M is the rank of his partner in M , i.e., r m (M (m)).The score of M is the sum of the scores of all men, i.e., ∑ m r m (M (m)).The man-optimal score of I, denoted M O(I), is the score of the man-optimal stable matching M 0 of I.
Let k be a positive integer.If Ĩ is an instance obtained by changing the preference lists of at most k men in I in some way, then we say that Ĩ is a k-neighbor of I. Suppose that Ĩ is a k-neighbor obtained by changing the preference lists of m1 , m2 , . . ., mℓ (ℓ ≤ k) and let M0 be the man-optimal stable matching for Ĩ.The man-optimal score of Ĩ with respect to I, denoted M O I ( Ĩ), is the score of M0 where m1 , m2 , . . ., mℓ 's scores are measured in terms of their preference lists in I. (Intuitively, their scores are measured in their true preference lists.)We say that Ĩ is proper if each man receives at least as good a partner in M0 as in M 0 , i.e., r m ( M0 (m)) ≤ r m (M 0 (m)) for each m, where m1 , m2 , . . ., mℓ 's scores are measured in their preference lists in I.
The problem MAX MAN-OPT IMPROVE(k) (MMI(k) for short) is, given a stable marriage instance I, to find a proper k-neighbor

Reduced Lists and Rotation Digraphs
In constructing algorithms and proving W [1]-hardness, we use reduced lists and rotation digraphs.These are defined on an instance I and its stable matching M , and are constructed in the following way: For each man m and each woman w below M (m) in m's preference list, delete w from m's list and m from w's list.The resulting preference lists are called the woman-oriented reduced lists with respect to I and M , denoted RL I,M .(We may simply call them the reduced lists if there is no ambiguity).Note that for each woman w, M (w) lies at the top of w's reduced list since M is stable.For each woman w, let next I,M (w) be the man at the second position of w's reduced list (if any).The woman-oriented rotation digraph with respect to I and M (or simply the rotation digraph) is a digraph D I,M = (V, A) where V is the set of men and A includes an arc (M (w), next I,M (w)) (i.e., a directed edge from M (w) to next I,M (w)) for each woman w such that next I,M (w) exists.Suppose that there is a directed cycle m 0 , m 1 , . . ., m r−1 (r ≥ 2) in D I,M , and let w i = M (m i ) for all i (0 ≤ i ≤ r − 1).Then we call an ordered list of pairs ρ = (m 0 , w 0 ), (m 1 , w 1 ), . . ., (m r−1 , w r−1 ) a rotation exposed in M .If we modify M by removing the pairs of rotation ρ and adding (m i , w i−1 mod r ) for each i, then the resulting matching is also stable [2].In this case we say that the new matching is obtained by eliminating the rotation ρ from M .Note that by eliminating a rotation, every man in the rotation obtains a better partner, while every woman in the rotation obtains a worse partner.It is also known that M is the man-optimal stable matching of I if and only if there is no rotation exposed in M (or equivalently, D I,M has no directed cycle) [2].

Optimization Variant
Let I be a given instance and M 0 be its man-optimal stable matching.Let us fix a man m whose preference list is to be changed.The following proposition, due to Huang [3], is useful for our purpose.Recall that a preference list is ordered from left to right in increasing order of the rank.
denotes the left (right) part of M 0 (m) in m's list.Let I ′ be an instance constructed in the following way: Take any number of women from P L (m), move them to the right of M 0 (m), and arbitrarily permute each of the (new) left and right parts of M 0 (m).Let M ′ 0 be the man-optimal stable matching for I ′ .Then in M ′ 0 no man is worse off than in M 0 (with respect to preference order of I).
Then we can claim that there is an optimal solution in which M 0 (m) lies at the top of m's list for the following reason: Note that m cannot be matched with a woman worse than M 0 (m) by the requirement of the problem.On the other hand, it is shown in [2] (page 56, Theorem 1.7.1) that m cannot get a better man-optimal partner by falsifying his preference list.Hence, in any feasible solution, m must be matched with M 0 (m).If M 0 (m) is not at the top of m's list in some feasible solution, we can move women on the left of M 0 (m) to the right of M 0 (m) without increasing the man-optimal score, by Proposition 3.1.Hence our claim holds.Since m is matched with M 0 (m) in a feasible solution, the order of women other than M 0 (m) in m's list is not important.Hence all we need to do is to move M 0 (m) to the top of m's list, which implies the following simple Algorithm 1.
Example.We give an example of the execution of Algorithm 1 for instance I given in Figure 1.The man-optimal stable matching M 0 is given in Figure 1 and M O(I) = 21.At line 2, we first consider m 1 .At line 3, we construct an instance I m 1 by moving w 5 to the top of m 1 's list.By applying GS, we find that the man-optimal stable matching of  Apply GS to I m and find its man-optimal stable matching M m .5: end for 6: Let m * be a man such that the score of M m * is minimum.7: Output I m * .
Since GS runs in time O(n 2 ), line 1 and the body of the for loop can be executed in time O(n 2 ).Since there are n men, the overall time complexity of Algorithm 1 is O(n 3 ).Theorem 3.2 MMI(1) can be solved in O(n 3 ) time.

Decision Variant
Note that a direct application of Algorithm 1 solves PMI (1) in O(n 3 ) time.We improve this to O(n 2 ) using a structural property of stable matchings.Let I be an input.From the discussion in Section 3.1, it suffices to consider the instance I m for each man m (see the description of Algorithm 1 for the definition of I m .)It is not hard to see that the man-optimal stable matching M 0 of I is also stable in I m for any m.Hence, if M 0 is not the man-optimal stable matching of I m for some m, then the man-optimal stable matching of I m is better than M 0 , so the answer is "yes"; otherwise, the answer is "no".To check whether M 0 is the man-optimal stable matching of I m or not in time O(n) per man, we use the woman-oriented rotation digraphs defined in Section 2.2.
Given I, we construct the rotation digraph D I,M 0 with respect to the man-optimal stable matching M 0 .Clearly it is acyclic.For a man m, we construct the instance I m (defined before) and the rotation digraph D Im,M 0 (recall that M 0 is stable in I m and hence D Im,M 0 is defined).From the discussion in Section 2.2, we know that M 0 is the man-optimal stable matching of I m if and only if D Im,M 0 contains no cycle.Hence our task can be reduced to checking if D Im,M 0 contains a cycle.The pseudocode of our algorithm is given as Algorithm 2: Algorithm 2 1: Find the man-optimal stable matching M 0 of I.   Output "yes" and terminate.
Example.We give an example of the execution of Algorithm 2 for instance I of Figure 1.The man-optimal stable matching M 0 is depicted in Figure 1.In constructing the reduced lists RL I,M 0 , we delete w 5 from m 2 , m 3 , m 4 , and m 5 's lists, and m 2 , m 3 , m 4 , and m 5 from w 5 's list.Hence RL I,M 0 is as follows: For a better exposition, let us first choose m 5 at line 3.To construct I m 5 , we move w 4 to the top of m 5 's list.We then delete w 1 , w 2 , and w 3 from m 5 's list and m 5 from w 1 , w 2 , and w 3 's lists in RL I,M 0 , and we obtain the following RL Im 5 ,M 0 : Note that the reduced lists RL Im,M 0 can be constructed from RL I,M 0 by deleting each woman w who precedes M 0 (m) from m's preference list, and correspondingly m from w's list.If m is not next I,M 0 (w), then next Im,M 0 (w) = next I,M 0 (w).Otherwise, i.e., if next I,M 0 (w) = m, then the man (say, m ′ ) at the third position of RL I,M 0 (if any) will be at the second position of RL Im,M 0 , i.e., next Im,M 0 (w) = m ′ .Accordingly we must replace the directed edge (M 0 (w), m) by (M 0 (w), m ′ ).By doing this for every such w, we can obtain D Im,M 0 in time O(n).Theorem 3.3 PMI(1) can be solved in O(n 2 ) time.

Hardness Result
In this section, we show W[1]-hardness of MMI(k).This hardness implies that MMI(k) probably does not admit an FPT algorithm with parameter k, i.e., an O(f (k) • p(n))-time algorithm where f is any function and p is a polynomial.

Theorem 4.1 MMI(k) with parameter k is W[1]-hard.
Proof.The Densest k Subgraph problem (DkS) [4] is the following problem.We are given a graph G and a positive integer k.The task is to find an induced subgraph of G with k vertices that contains the maximum number of edges.It is known that DkS is W[1]-hard with parameter k [5].We give an FPT-reduction from DkS to MMI(k).
Given an instance (G, k 1 ) of DkS, we construct an instance (I, k 2 ) of MMI(k) as follows.First, we let k 2 = k 1 .Next, we construct I from G = (V, E).For each vertex v i ∈ V , we construct a man m i and a woman w i .For each edge (v i , v j ) ∈ E, we construct two men m i,j and m ′ i,j and two women w i,j and w ′ i,j .For a vertex v i ∈ V , let E i ⊆ E be the set of edges incident to v i and W i be the set of women w i,j corresponding to E i .Each person's preference list is constructed as follows, where L(W i ) is an arbitrarily ordered list of women in W i and "• • •" means an arbitrarily ordered list of those people who do not appear explicitly in the list.
It is not hard to see that the man-optimal stable matching M 0 of I consists of pairs (m i , w i ) for 1 ≤ i ≤ |V | and (m i,j , w i,j ) and (m ′ i,j , w ′ i,j ) for (i, j) ∈ E. Note that if we ignore the "• • •" part in the above preference lists, each man is matched with the last woman and each woman is matched with the first man in M 0 .Hence these are the woman-oriented reduced lists with respect to I and M 0 , i.e., RL I,M 0 .
Clearly, the reduction can be performed in time polynomial in |G|.To complete the proof, we show that G has an induced subgraph with k 1 vertices and at least s edges if and only if there is a proper in the following we use k to denote k 1 and k 2 just for simplicity.First, suppose that G has an induced subgraph with k vertices and at least s edges, and let S(⊆ V ) be the set of those k vertices.Then, for each v i ∈ S, we modify m i 's preference list by moving his man-optimal partner w i to the top of the list, and let Ĩ be the resulting instance.We will show that, by doing this, m i,j and m ′ i,j 's scores in the man-optimal stable matching of Ĩ are decreased by one respectively, if v i , v j ∈ S and (v i , v j ) ∈ E. Since there are at least s such edges, the score is decreased by at least 2s in total.
Recall that w i,j 's reduced list in RL I,M 0 is "m i,j m i m j m ′ i,j ".Since v i , v j ∈ S and m i and m j 's preference lists are modified as mentioned above, w i,j 's reduced list in RL Ĩ,M 0 becomes "m i,j m ′ i,j ", i.e., next Ĩ,M 0 (w i,j ) = m ′ i,j .Note that w ′ i,j 's reduced list "m ′ i,j m i,j " is unchanged.Then we have a directed cycle m i,j m ′ i,j of length two in D Ĩ,M 0 and if we eliminate this rotation, the scores of m i,j and m ′ i,j will each be decreased by one.Note that we can repeat this argument independently for each edge.
Next, suppose that there is a proper k-neighbor Ĩ of I such that M O(I) − M O I ( Ĩ) ≥ 2s and let M0 be the man-optimal stable matching of Ĩ.First, note that in M0 , each man is matched with a woman on the reduced lists RL I,M 0 because by the condition of the problem, no man can be worse off in M0 than in M 0 .Since M0 is a perfect matching, we know that M0 (m i ) = w i for each i (1 ≤ i ≤ |V |) and either " M0 (m i,j ) = w i,j and M0 (m ′ i,j ) = w ′ i,j " or " M0 (m i,j ) = w ′ i,j and M0 (m ′ i,j ) = w i,j " for each (v i , v j ) ∈ E. Therefore, only the case of " M0 (m i,j ) = w ′ i,j and M0 (m ′ i,j ) = w i,j ", the scores of m i,j and m ′ i,j will each be decreased by one.This can happen only when m ′ i,j becomes next Ĩ,M 0 (w i,j ), that is, m i and m j are removed from w i,j 's reduced list.This implies that w i precedes w i,j in m i 's reduced list and w j precedes w i,j in m j 's reduced list.Therefore, both m i and m j 's lists are modified in Ĩ.Since M O(I) − M O I ( Ĩ) ≥ 2s, there are at least s such pairs (i, j).Let S be the set of vertices v i such that m i 's preference list is modified in constructing Ĩ.Then |S| ≤ k and by the above discussion, S induces at least s edges, which completes the proof.

Optimization Variant
From the discussion in Section 3.1, it seems that it would suffice to choose k men whose preference lists are to be modified, and move their man-optimal partners to the top of their respective preference lists.If this is true, we obtain an O(n k+2 )-time algorithm since there are O(n k ) combinations of selecting k men and for each of them, we run GS whose time complexity is O(n 2 ).However, the following example (Figure 3) shows that this is not true.
Nevertheless, the following lemma allows the search space to be bounded.Man-optimal partners are underlined.An optimal solution is obtained by moving w 4 and w 5 to the top in m 4 's and m 5 's preference lists respectively, as a result of which the score decreases by seven.Any choice of two men and moving their man-optimal partners to the top decreases the score by at most five.
Lemma 4.2 For an instance I, let I opt be an optimal solution and M opt be the man-optimal stable matching of I opt .Let S (|S| ≤ k) be the set of men whose preference lists are modified in I opt .Let Ĩ be the instance obtained from I by moving M opt (m) to the top of m's list for each m ∈ S. Then M opt is stable, and in fact man-optimal stable, for Ĩ.
Proof.Suppose that M opt has a blocking pair in Ĩ.Each m ∈ S cannot be a part of a blocking pair because M opt (m) lies at the top of m's list.But men not in S and all the women have the same preference list in I opt and Ĩ, so if (m ′ , w ′ ) is a blocking pair for M opt in Ĩ, then (m ′ , w ′ ) is also a blocking pair for M opt in I opt , a contradiction.Hence M opt is stable for Ĩ.Now suppose that M opt is not man-optimal for Ĩ and let M ′ (̸ = M opt ) be the man-optimal stable matching for Ĩ.Since M opt matches every man in S to his top choice in Ĩ, so does M ′ .Thus some of the men not in S (whose preference lists are the same in I and Ĩ) obtain better partners in M ′ than in M opt .This means that M O I ( Ĩ) < M O I (I opt ), which contradicts the optimality of I opt .
By the definition of the problem, each man is matched in M opt to the woman M 0 (m) or a woman preceding M 0 (m).Hence by Lemma 4.2, if we fix the set of ℓ men whose preference lists are to be modified, it suffices to bring, for each selected man m, M 0 (m) or a woman preceding M 0 (m) to the top.Furthermore, we know that there is no stable matching for I opt in which every man in S is matched to a woman strictly better than his man-optimal partner in M 0 [2].Hence for at least one man m * in S, M opt (m * ) = M 0 (m * ).
Putting these observations together, we have the following Algorithm 3. Let X be the set of men in a given instance.
Note that the operation of line 6 includes the case of leaving m i 's preference list unchanged.Therefore at least one execution of Algorithm 3, i.e., an execution for which m * in the above discussion is selected in line 2 as m and the rest of the ℓ − 1 men in S are selected in line 4, creates Ĩ in Lemma 4.2 and hence finds an optimal solution.The overall running time of Algorithm 3 is for each combination of k − 1 women (w 1 , . . ., w k−1 ) such that each w i is M 0 (m i ) or precedes M 0 (m i ) in m i 's list of I do Move w i to the top of m i 's preference list.Apply GS to the current instance and find its man-optimal stable matching.9: end for 10: end for 11: Output the instance that minimizes the man-optimal score.

Decision Variant
A straightforward extension of Sections 3.2 and 4.2 is as follows.We first find the man-optimal stable matching M 0 and construct the reduced list RL I,M 0 and the rotation digraph D I,M 0 using O(n 2 ) time.For each of the O(n 2k−1 ) possible modifications of preference lists, we modify D I,M 0 in time O(kn) and check if the resulting graph contains a directed cycle in time O(n).If at least one execution creates a directed cycle, then the answer is "yes", otherwise "no".This results in the time complexity of O(n 2 + n 2k−1 (kn + n)) = O(kn 2k ).
We can reduce the search space significantly using the following idea.Suppose that input I is a "yes"-instance of PMI(k), and let I opt be its optimal solution (when I is viewed as an MMI(k) instance).Let S (|S| ≤ k) be the set of men whose preference lists are modified in I opt .From the discussion in Section 4.2, we can assume that in the preference list of one man m * , M 0 (m * ) is moved to the top in I opt , and in the preference list of other men m(∈ S − {m * }), M 0 (m) or a woman preceding M 0 (m) is moved to the top.Clearly, the rotation digraph D Iopt,M 0 must contain a directed cycle.Now, define S ′ (⊆ S) as S ′ = {m | M 0 (m) is moved to the top of m's list in I opt } and consider the instance Ī constructed from I by moving M 0 (m) to the top of m's list for each m ∈ S ′ (and leaving m's preference list for each m / ∈ S ′ unchanged).By the construction of reduced lists and rotation digraphs, it is not hard to see that DĪ ,M 0 is identical to D Iopt,M 0 and hence DĪ ,M 0 contains a directed cycle.(This can be seen as follows: If a man m is in S ′ or not in S, then m's preference list is the same in I opt and Ī.If a man m is in S − S ′ , then the set of women preceding M 0 (m) in m's preference list is the same in I opt and Ī.) Therefore, it suffices, for each combination of choosing i(≤ k) men, to move their man-optimal partners to the top of the lists, to modify the rotation digraph accordingly in O(in) time, and to check if the resulting digraph contains a directed cycle in O(n) time.The overall time complexity is Theorem 4.4 PMI(k) can be solved in O(n k+1 ) time.

Changing n Men's Preference Lists
In this section, we show that MMI(k) and PMI(k) become easy if we are allowed to change any number of men's preference lists.We first consider the optimization variant.Consider an instance I and its man-optimal stable matching M 0 .By the requirement of the problem, in a new matching each man m should be matched with the woman M 0 (m) or a woman preceding M 0 (m) in m's list in I; in other words, each man should be matched with a woman on the reduced lists RL I,M 0 .Let M * be a minimum score perfect matching with this property.If we move M * (m) to the top of m's list for each m, we are done because M * is clearly the man-optimal stable matching of the resulting instance.
It is easy to find M * : We construct the edge-weighted bipartite graph G = (V, U, E) where V and U are the sets of men and women respectively, and (m, w) ∈ E if and only if w appears on m's reduced list in RL I,M 0 .The weight of (m, w) is the rank of w in m's list in I, that is, r m (w).We can obtain M * by finding a minimum cost perfect matching in G, which can be done in O(n 2.5 log n) time [6,7].Since finding M 0 and constructing RL I,M 0 can be done in O(n 2 ) time, the overall time complexity is O(n 2.5 log n).As for the decision variant, we do not need to find a minimum cost perfect matching but it suffices to check if M 0 can be Pareto improved.We can do this by constructing the digraph G = (V, A), where each vertex of G corresponds to a woman in a given instance I.For each man m, we include an arc from M 0 (m) to each woman preceding M 0 (m) in m's preference list.It is not hard to see that M 0 can be Pareto improved if and only if G contains a directed cycle.As mentioned in the analysis of the time complexity of Algorithm 2 in Section 3.2, we can check whether G contains a directed cycle or not by a topological sorting algorithm in time linear in the size of G. Since the size of G is O(n 2 ), it is not hard to see that the overall time complexity is O(n 2 ).Theorem 5.2 PMI(n) can be solved in O(n 2 ) time.

Conclusions
In this paper we considered the problem of changing at most k men's preference lists to improve man-optimal stable matchings.We have proved that the problem is W[1]-hard with the parameter k.We also presented O(n 2k+1 )-time and O(n k+1 )-time exact algorithms for the optimization and decision variants, respectively.Finally, we have presented O(n 2.5 log n)-time and O(n 2 )-time algorithms for the optimization and decision variants, respectively, when k = n.Since the problem is important when k is small, it is interesting future work to reduce the time complexity of MMI(1) from O(n 3 ) to o(n 3 ).Another future work is to determine whether PMI(k) is NP-complete or not.

1 :
w 2 ), (m 3 , w 3 ), (m 4 , w 4 ), (m 5 , w 1 )} and M O I (I m 1 ) = 9.Next, we consider m 2 .The instance I m 2 is constructed by moving w 1 to the top of m 2 's list.The man-optimal stable matching of I m 2 is also M 0 and M O I (I m 2 ) = 21.By continuing this, we can find that M O I (I m 3 ) = M O I (I m 4 ) = M O I (I m 5 ) = 21.Hence, Algorithm 1 outputs I m 1 since M O I (I m 1 ) is the smallest.Algorithm 1 Find the man-optimal stable matching M 0 of I.2: for each man m do 3:Modify I by moving M 0 (m) to the top of m's list.Let I m be the resulting instance.

2 :
Construct D I,M 0 .3: for each man m do

4 :
Modify I by moving M 0 (m) to the top of m's list.Let I m be the resulting instance.

w 4 : m 5 m 1 m 2 m 3 m 4 m 5 : w 4 w 5 : m 1 5 : m 1
To construct the rotation digraph D Im 5 ,M 0 , we remove an arc (m 4 , m 5 ) from D I,M 0 and add (m 4 , m 1 ) because next I,M 0 (w 3 ) = m 5 but next Im 5 ,M 0 (w 3 ) = m 1 .The resulting D Im 5 ,M 0 is depicted in Figure2(b).This digraph D Im 5 ,M 0 contains no cycle and hence we proceed to the next man.Next, suppose that we choose m 1 at line 3. Then RL Im 1 ,M 0 is as follows:m 1 : w 5 w 1 : m 2 m 3 m 4 m 5 m 2 : w 2 w 3 w 4 w 1 w 2 : m 3 m 4 m 5 m 2 m 3 : w 3 w 4 w 1 w 2 w 3 : m 4 m 5 m 2 m 3 m 4 : w 4 w 1 w 2 w 3 w 4 : m 5 m 2 m 3 m 4 m 5 : w 1 w 2 w 3 w 4 wTo construct the rotation digraph D Im 1 ,M 0 , we remove an arc (m 5 , m 1 ) from D I,M 0 and add (m 5 , m 2 ) and obtain D Im 1 ,M 0 in Figure2(c).Since D Im 1 ,M 0 contains a cycle, Algorithm 2 outputs "yes" and terminates.Lines 1 and 2 can be performed in time O(n 2 ).Checking whether D Im,M 0 contains a directed cycle or not can be done by a standard topological sorting algorithm in time linear in the size of D Im,M 0 .Since each vertex of D Im,M 0 has outdegree at most one, the size of D Im,M 0 is O(n) and line 6 can be done in O(n) time.Shortly, we show that D Im,M 0 can be constructed from D I,M 0 in time O(n).Then the overall time complexity of Algorithm 2 is O(n 2 ).

Figure 3 .
Figure3.A counter example for the naive algorithm where k = 2. Man-optimal partners are underlined.An optimal solution is obtained by moving w 4 and w 5 to the top in m 4 's and m 5 's preference lists respectively, as a result of which the score decreases by seven.Any choice of two men and moving their man-optimal partners to the top decreases the score by at most five.

Theorem 4 . 3 3 1: 4 :
MMI(k)  can be solved in O(n 2k+1 ) time.Algorithm Find the man-optimal stable matching M 0 of I.2: for each man m do 3:Move M 0 (m) to the top of m's list.for each choice of k − 1 men (m 1 , . . ., m k−1 ) from X − {m} do 5:

Theorem 5 . 1
MMI(n) can be solved in O(n 2.5 log n) time.