# Refined Computational Complexities of Hospitals/Residents Problem with Regional Caps

The Hospitals/Residents problem (HR) is a many-to-one matching problem whose solution concept is stability. It is widely used in assignment systems such as assigning medical students (residents) to hospitals. To resolve imbalance in the number of residents assigned to hospitals, an extension called HR with regional caps (HRRC) was introduced. In this problem, a positive integer (called a regional cap) is associated with a subset of hospitals (called a region), and the total number of residents assigned to hospitals in a region must be at most its regional cap. Kamada and Kojima defined strong stability for HRRC and demonstrated that a strongly stable matching does not necessarily exist. Recently, Aziz et al. proved that the problem of determining if a strongly stable matching exists is NP-complete in general. In this paper, we refine Aziz et al.'s result by investigating the computational complexity of the problem in terms of the length of preference lists, the size of regions, and whether or not regions can overlap, and completely classify tractable and intractable cases.

Comments

There are no comments yet.

## Authors

• 6 publications
• 6 publications
• ### Strongly Stable and Maximum Weakly Stable Noncrossing Matchings

In IWOCA 2019, Ruangwises and Itoh introduced stable noncrossing matchin...
01/23/2020 ∙ by Koki Hamada, et al. ∙ 0

read it

• ### Cutoff stability under distributional constraints with an application to summer internship matching

We introduce a new two-sided stable matching problem that describes the ...
02/05/2021 ∙ by Haris Aziz, et al. ∙ 0

read it

• ### An Algorithm for Strong Stability in the Student-Project Allocation Problem with Ties

We study a variant of the Student-Project Allocation problem with lectur...
11/21/2019 ∙ by Sofiat Olaosebikan, et al. ∙ 0

read it

• ### From Matching with Diversity Constraints to Matching with Regional Quotas

In the past few years, several new matching models have been proposed an...
02/17/2020 ∙ by Haris Aziz, et al. ∙ 2

read it

• ### Robustness of Regional Matching Scheme over Global Matching Scheme

The paper has established and verified the theory prevailing widely amon...
05/03/2000 ∙ by Liang Chen, et al. ∙ 0

read it

• ### Popular Matching in Roommates Setting is NP-hard

An input to the Popular Matching problem, in the roommates setting, cons...
03/25/2018 ∙ by Sushmita Gupta, et al. ∙ 0

read it

• ### Una valutazione di copertura, qualita ed efficienza dei servizi sanitari regionali tra 2010 e 2013

An application of Multiplicative Non-Parametric Corporate Performance Mo...
11/23/2018 ∙ by Filippo Elba, et al. ∙ 0

read it

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

An instance of the Hospitals/Residents problem (HR for short) is a many-to-one generalization of the stable marriage problem. Its instance consists of a set of residents and a set of hospitals, each of whom has a preference list that strictly orders a subset of the members of the other side. Furthermore, each hospital has a capacity, which specifies the maximum number of residents it can accommodate. A matching is an assignment of residents to hospitals in which the number of residents assigned to each hospital does not exceed its capacity. A blocking pair of a matching is a pair of a resident and a hospital , where assigning to improves the situation of both and . A matching that admits no blocking pair is a stable matching. Gale and Shapley [GS62] showed that a stable matching exists in any HR instance, and proposed a polynomial-time algorithm to find one, which is known as the Gale-Shapley algorithm.

HR is quite popular in practical assignment systems, such as assigning students to high schools [APR05, APRS05] or assigning residents to hospitals [Rot84]. One of the major issues in the residents-hospitals assignment is imbalance in the number of residents assigned to hospitals. For example, hospitals in urban areas are generally more popular and hence likely to be assigned more residents than those in rural areas. In fact, it is reported that rural hospitals in Japan suffer from shortage of doctors [KK10, KK12]. One of the solutions to resolve this problem might be to find a stable matching that assigns more residents to rural hospitals than one found by a frequently used algorithm, such as the Gale-Shapley algorithm. However, this approach fails since the number of residents assigned to each hospital is invariant over stable matchings, due to the famous Rural Hospital theorem [GS85, Rot84, Rot86].

There have been some attempts to resolve this problem by reformulating HR. One is to set a lower quota to each hospital, which denotes a minimum number of residents required by that hospital. It is easy to see that, by the Rural Hospitals theorem, there may exist no stable matching that satisfies all the lower quotas. In some model, a hospital is allowed to be closed if the number of residents cannot reach its minimum quota [BFIM10], or in another model, it is mandatory to satisfy all the lower quotas, while stability is considered as a soft constraint [HIM16]. Another formulation is to set a regional cap to a region consisting of some hospitals, and require the total number of residents assigned to hospitals in the region to be at most its regional cap [BFIM10, KK10]. We denote this problem the HR with Regional Caps (HRRC for short). We can expect to reduce imbalance in the number of residents by carefully setting the regional caps to urban areas. However, again due to the Rural Hospital theorem, a stable matching satisfying all the regional caps may not exist.

Kamada and Kojima [KK10, KK15] defined several stability notions for HRRC; among them, the most natural one is the strong stability [KK15]. They presented an HRRC-instance that admits no strongly stable matching, but the computational complexity of the problem of determining the existence of a strongly stable matching had been open up to recently. In 2020, Aziz et al. [ABB20] resolved this problem by showing that it is NP-complete. This hardness holds even if any two regions are disjoint (in other words, each hospital is contained in at most one region) and the size of each region is at most two (i.e., each region contains at most two hospitals). In their reduction, the length of preference lists are unbounded on both sides, hence one of possible next steps might be to investigate if the problem becomes tractable when it is bounded.

### 1.1 Our Contributions

In this paper, we refine Aziz et al.’s work [ABB20] by investigating the computational complexity of the problem in various restrictions. Let Strong--HRRC denote the problem of determining if a strongly stable matching exists in an HRRC instance where the length of a preference list of each resident is at most , the length of a preference list of each hospital is at most , and the size of each region is at most . We use to mean that the corresponding parameter is unbounded. Next, let HRRCDR be the restriction of HRRC where any two regions are disjoint, and Strong--HRRCDR be defined analogously as for HRRC. Note then that the above mentioned hardness result by Aziz et al. [ABB20] can be rephrased as NP-completeness of Strong--HRRCDR.

In this paper, we completely determine the computational complexity of the problem in terms of the restrictions mentioned above. Our results are summarized as follows. First we give results for HRRC.

• Strong--HRRC is in P. (Theorem 1)

• Strong--HRRC is in P. (Theorem 2)

• Strong--HRRC is in P. (Theorem 3)

• Strong--HRRC is NP-complete. (Theorem 4)

Hence the problem is tractable if at least one parameter is 1, while it is intractable even if all the parameters are 2. We remark that, for all the positive results (Theorems 3, 2 and 1), we have also shown that a strongly stable matching always exists. Next, we give results for HRRCDR.

Corollaries 3, 2 and 1 are immediate from Theorems 3, 2 and 1, respectively, since HRRCDR is a special case of HRRC. In contrast to HRRC, the problem is tractable if all the parameters are 2, but it becomes intractable if one parameter is raised to 3. Note that Theorems 7 and 8 are strengthening of Aziz et al.’s NP-completeness [ABB20].

### 1.2 Related Work

Besides strong stability, Kamada and Kojima [KK10, KK15] defined weak stability and stability in HRRC. Weak stability is weaker than strong stability and stability lies between them. They showed that there always exists a weakly stable matching [KK17], but the proof is not constructive. For stability, they showed that a stable matching always exists and can be found by a strategyproof algorithm when the set of regions forms a laminar structure [KK18], i.e, for any two regions, either they are disjoint or one is contained in the other.

Biró et al. [BFIM10] proposed a restriction of HRRC, where each region has a common preference list and a preference list of any hospital in the region must be a result of deleting some residents from the common preference list. They proved that the problem of determining existence of a stable matching is NP-complete even in a very restrictive case. They also showed that the problem can be solved in polynomial time if the set of regions is laminar.

In Goto et al. [GIK16]’s model, preference lists are complete and each region has a lower quota as well as an upper quota. They presented two strategyproof algorithms to find a fair matching when the set of regions is laminar. Here, fairness is a weakened notion of the stability in HR, where certain types of blocking pairs are allowed to exist.

## 2 Preliminaries

### 2.1 Definitions for Stable Matching Problems

An instance of Hospitals/Residents problem (or HR for short) consists of a set of residents, a set of hospitals, a collection of preference lists, and a mapping that represents capacities of hospitals, where is the set of all nonnegative integers. The agents in are the residents and hospitals in . Each agent has a strictly ordered preference list, denoted by , over a subset of the members of the opposite set. If an agent prefers to , we write . If an agent is included in an agent ’s preference list, we say that is acceptable to . If and are acceptable to each other, is said to be an acceptable pair. We assume that acceptability is mutual, that is, is acceptable to if and only if is acceptable to . Each hospital has a nonnegative integral capacity, denoted by .

An assignment is a subset of . If , is said to be assigned to , and is assigned . For each , the set of assignees of in is denoted by . For , we write . For , if , is said to be unassigned, otherwise is assigned. A hospital is undersubscribed, or full according as is less than, or equal to , respectively. A hospital is said to be empty if . For notational convenience, given an assignment and a resident such that , we also use to refer to the unique hospital when there is no ambiguity. A matching is an assignment that satisfies all of the following conditions: (i) for any , is an acceptable pair; (ii) for any , ; (iii) for any , .

###### Definition 1

Let be an instance of HR and be a matching of . A pair is a blocking pair (or BP for short) for (or blocks ) if all of the following conditions are satisfied: (i) is an acceptable pair; (ii) either is unassigned, or prefers to ; (iii) either is undersubscribed, or prefers to at least one member of . If a matching admits no BP, we say that is stable.

Gale and Shapley showed that every instance of HR admits a stable matching, and proposed an -time algorithm for finding one [GS62]. The algorithm is known as the resident-oriented Gale-Shapley algorithm (or RGS algorithm for short).

An instance of Hospitals/Residents problem with Regional Caps (or HRRC for short) is where , , , are as before. A region is a non-empty subset of , and is a set of regions. Each region has a nonnegative integral regional cap, denoted by . For an assignment , a region is deficient, or full according as is less than, or equal to , respectively.

###### Definition 2

Let be an instance of HRRC and be an assignment of . If for all , is said to be feasible, otherwise is infeasible.

###### Definition 3

Let be an instance of HRRC. A BP for a matching is a strong blocking pair (or SBP for short) for if satisfies at least one of the following conditions: (i) is feasible; (ii) there exists such that . If a feasible matching admits no SBP, we say that is strongly stable.

Note that if is unassigned in , since .

As the definition states, a BP for a matching is tolerated to exist if (i) moving to violates a regional cap, and (ii) has no incentive to accept by rejecting a resident in .

Kamada and Kojima [KK10, KK15] showed that, in contrast to HR, there exists an instance that does not admit a strongly stable matching, as shown below. We refer to this instance, which plays an important role in our hardness proofs, as .

###### Example 1

Let be a set of residents, be a set of hospitals, and be a set of regions. Here and hereafter, we illustrate agent ’s preference list by putting “” just after the agent’s name and listing acceptable agents of in decreasing order of ’s preference. We also denote to represent that a hospital ’s capacity is . represents that the regional cap for a region is . The preference lists, capacities of hospitals, and regional caps are as follows.

 r1: r2: h1 h2 h2 h1
 h1[1]: h2[1]: r2 r1 r1 r2
 c\hifempty\seth1,h2(\seth1,h2):=1

Let Hospitals/Residents problem with Regional Caps and Disjoint Regions (or HRRCDR for short) denote the restriction of HRRC in which any two regions are disjoint. Here, we say that two regions and are disjoint if . Let be the set of all positive integers. Given three integers , , and , let -HRRC (respectively -HRRCDR) denote the restriction of HRRC (respectively HRRCDR) in which each resident’s preference list is of length at most , each hospital’s preference list is of length at most , and each region’s size (i.e., the number of hospitals in the region) is at most . or means that the lengths of preference lists are unbounded, and means that the sizes of regions are unbounded.

Let Strong--HRRC (Strong--HRRCDR, respectively) denote the problem of determining if a strongly stable matching exists in an HRRC instance (an HRRCDR instance, respectively).

### 2.2 SAT and Its Restricted Variants

We introduce an NP-complete problem SAT [Coo71] and its restricted variants. We will use them later in our proofs for NP-completeness.

An instance of SAT consists of a set of variables and a set of clauses. Each variable takes either true () or false (). If is a variable, then and its negation are literals. A clause is a disjunction of literals. A clause is satisfied if and only if at least one of its literals is . We say that a SAT-instance is satisfiable if and only if there exists a / assignment to variables that simultaneously satisfies all the clauses. Such an assignment is called a satisfying assignment. SAT asks if there exists a satisfying assignment. 3-SAT is a restriction of SAT, where each clause has exactly three literals. 3-SAT is also NP-complete [Coo71].

Another restriction, One-In-Three 3-SAT, is also an NP-complete problem [Sch78]. Its instance consists of a set of variables and a set of clauses over such that each clause in has exactly three literals. One-In-Three 3-SAT asks if there exists a satisfying assignment such that each clause in has exactly one true literal. One-In-Three 3-SAT remains NP-complete even if no clause in contains a negated literal [Sch78]. We refer to One-In-Three 3-SAT with such restricted instances as One-In-Three Positive 3-SAT.

## 3 Hrrc with Intersecting Regions

In this section, we consider the case when regions may intersect. In this case, as we will show in Theorems 3, 2 and 1, there always exists a strongly stable matching in a -HRRC-instance if at least one of , , and is one. On the other hand, as we will show in Theorem 4, determining the existence of a strongly stable matching is NP-complete even if all of , , and are two.

### 3.1 Polynomial-time Algorithm for Strong-(∞,∞,1)-Hrrc

###### Theorem 1

There exists an -time algorithm to find a strongly stable matching, given an -HRRC-instance .

• The description of our algorithm is given in Algorithm 1.

We first show that the output is a strongly stable matching of . By the definition of , for all . Since is a matching of , is also a matching of because the capacities of hospitals and regional caps are the only difference between and . For each such that , . Therefore, (i) is a feasible matching of .

Suppose that there exists a BP for in . Let be one of such BPs. Since is not a BP for in , we have and (ii) for any , . Recalling that is a BP for in , . Thus, holds, and hence there exists such that and . By the assumption, , so holds. Let . Then, . Since , holds. Therefore, (iii) is infeasible in . By conditions (i) to (iii), is a strongly stable matching of .

We then show the time complexity. Since the size of each region is at most one, for any hospital , there exits at most one region that contains . Therefore, creftype 1 can be executed in time. Since all components of have been already constructed, creftype 2 can be executed in time. Since RGS algorithm runs in time, the whole time complexity is .

### 3.2 Polynomial-time Algorithm for Strong-(1,∞,∞)-Hrrc

###### Theorem 2

There exists an -time algorithm to find a strongly stable matching, given a -HRRC-instance .

• We show that

Algorithm 2 always outputs a strongly stable matching in time. For each , the algorithm greedily assigns the best possible residents to with respect to ’s preference, as long as capacities of the hospital and the regions including are not violated.

We first show the correctness. Let be at the end of the algorithm. We will prove that is a strongly stable matching of by showing that is feasible in and admits no SBP. The key observation is the monotonicity of the condition in creftype 5, i.e., for each , once the condition is unsatisfied, it will never be satisfied again after that.

We first show that is a feasible matching of . In the algorithm, the only operations on are the initialization to in creftype 1 and the append of a pair in creftype 6. Since the length of each resident’s preference list is at most one, creftype 4 implies that creftype 6 is executed at most once for each . Therefore, each resident appears in at most once. Further, in creftype 5, the algorithm checks whether appending to violates neither ’s capacity nor regional cap for any region that includes . Thus, is always feasible, and hence is also feasible.

Next, we show that the following two conditions hold for any BP for : (i) is infeasible, and (ii) for any , , which implies that is not an SBP. Note that holds, since the length of ’s preference list is exactly one and is the unique hospital in ’s list.

For contradiction, suppose that (ii) does not hold. Then, there exists a resident such that . This means that at some point was not assigned to , i.e., the condition in creftype 5 was not satisfied, but later was assigned to , i.e., the condition in creftype 5 was satisfied. This contradicts the monotonicity of the condition in creftype 5.

For contradiction, suppose that (i) does not hold. Since , , so is feasible. Also, because is a BP for and (ii) holds. Thus, the condition in creftype 5 for is still satisfied at the end of algorithm. However, was not added to , i.e., the condition in creftype 5 for was not satisfied. This contradicts the monotonicity of the condition in creftype 5 again.

We then analyze the time complexity of Algorithm 2. Since the length of each resident’s preference list is at most one, creftype 4 is executed at most times. To check the conditions and at creftype 5, we prepare a counter for each hospital and each region. Then, for processing each resident, checking the conditions at creftype 5 and updating the counters at creftype 6 can be done in time . Clearly updating the matching at creftype 6 can be done in constant time. Therefore, the algorithm runs in time.

### 3.3 Polynomial-time Algorithm for Strong-(∞,1,∞)-Hrrc

###### Theorem 3

There exists an -time algorithm to find a strongly stable matching, given an -HRRC-instance .

• We show that

Algorithm 3 always outputs a strongly stable matching in time. For each , the algorithm assigns to the best possible with respect to ’s preference list, as long as the capacity of and feasibility are not violated.

We first show the correctness. Let be at the end of the algorithm. It is easy to see that a matching is always feasible during the course of the algorithm, since is added to only when this addition does not violate feasibility. Hence is also feasible.

Next, let be any BP of (if any). Then is either unassigned or assigned to a hospital worse than in . Therefore, when the for-loop was executed for , was considered but did not satisfy the conditions in creftype 3. Since each hospital contains at most one resident in the preference list, is the only resident in ’s list. It must be the case that , as otherwise, cannot be a BP. Thus condition (i) in creftype 3 must be satisfied for and

, so condition (ii) was unsatisfied. This means that at this moment there is a region

that includes such that , and this equation is retained until the end of the algorithm, implying that . Note that if , is not in . Therefore violates and hence is not feasible, implying that is not an SBP. This completes the proof that is strongly stable.

We then analyze the time complexity of Algorithm 3. Since the length of each hospital’s preference list is at most one, testing the conditions in creftype 3 is executed at most times. To check the conditions and at creftype 3, we prepare a counter for each hospital and each region. Then, for processing each hospital, checking the conditions at creftype 3 and updating the counters at creftype 5 can be done in time . Clearly updating the matching at creftype 5 can be done in constant time. Therefore, the algorithm runs in time.

### 3.4 NP-completeness of Strong-(2,2,2)-Hrrc

###### Theorem 4

Strong--HRRC is NP-complete.

• Membership in NP is obvious. We show show a reduction from One-In-Three Positive 3-SAT. Let be an instance of One-In-Three Positive 3-SAT having variables () and clauses () of size three. We construct an HRRC-instance from . For each variable , we construct a variable gadget, which consists of a resident and a hospital . A variable gadget corresponding to is called an -gadget. For each clause , we construct a clause gadget. It contains two residents and , and two hospitals and . A clause gadget corresponding to is called a -gadget. Thus, there are residents and hospitals in the created HRRC-instance, denoted .

The preference lists and capacities of agents in the -gadget and the -gadget are constructed as shown in Figures 2 and 1, respectively. Suppose that ’s th literal () is . For each clause , we create regions of size two as follows: for each such that and , we add to the set of regions and set the regional cap of as . Now the reduction is completed. It is not hard to see that the reduction can be performed in polynomial time and the conditions on the preference lists and regions stated in the theorem are satisfied.

We then show the correctness. First, suppose that is satisfiable and let be a satisfying assignment. We construct a strongly stable matching of from . For an -gadget, add to if and only if under . No agent in -gadget is assigned. The construction of is now completed.

We show that is a feasible matching of . By the construction, is a matching of . For a clause , exactly one literal is under . Therefore, in , exactly one of , , and is assigned its first-choice resident. Also, neither nor is assigned in . Therefore, all the regional caps are satisfied. Thus, is feasible in .

Next, we show that has no SBP. All hospitals that are nonempty in are assigned their first-choice residents, so none of them is a part of an SBP. Let be an empty hospital and be a clause that contains . By the satisfiability of , there exists such that , but because . Then, is assigned its first-choice resident in . Since , is not a part of an SBP. For hospitals and , there exists a hospital that is assigned its first-choice resident. Since and , neither nor is a part of an SBP. Thus, is a strongly stable matching.

Conversely, suppose that admits a strongly stable matching . We construct a satisfying assignment of . For each , if then we set in ; otherwise, we set in .

We show that satisfies . Suppose not. Then, there exists a clause such that either (i) none of the literals are , or (ii) at least two literals are . In the case (i), all of , , and are empty. Therefore, regional caps and () do not affect the matching among , , , and . Then, these four agents form the same structure as in Example 1, so there exists an SBP no matter how they are assigned, a contradiction. In the case (ii), let and be two literals that take a value of . Then, both and hold. Since they have a regional cap of , is infeasible, a contradiction. Thus, satisfies .

## 4 Hrrc with Disjoint Regions

In this section, we consider the case when regions are disjoint. Since HRRCDR is a special case of HRRC, the following corollaries are immediate from Theorems 3, 2 and 1.

###### Corollary 1

Strong--HRRCDR is in P.

###### Corollary 2

Strong--HRRCDR is in P.

###### Corollary 3

Strong--HRRCDR is in P.

Hence, in the rest of this section, we consider cases where each parameter is at least two. We first show a positive result in Section 4.1. Then, in Section 4.2, we introduce an NP-complete variant of SAT, which will be used in the negative results in Sections 4.4, 4.5 and 4.3.

### 4.1 Polynomial-time Algorithm for Strong-(2,2,2)-Hrrcdr

In this section, we give a polynomial-time algorithm for Strong--HRRCDR. A high-level idea of the algorithm is as follows. Given an instance , we first divide it to subinstances. Let a -subinstance be a subinstance of consisting of two residents and two hospitals such that each () includes both and in the preference list, each () includes both and in the preference list, and and are included in the same region. Since regions are disjoint, a -subinstance has no interference with the rest of the instance. Suppose that contains -subinstances . Remove all of them from and let be the resultant subinstance.

We then handle these subinstances independently. Each -subinstance is solved by a brute-force search. Before solving the subinstance , to simplify the analysis, we apply the shrinking operation described in Section 4.1.1. It modifies capacities of hospitals but does not change the set of strongly stable matchings. Then, is solved by a sub-algorithm Algorithm 4, which will be provided in Section 4.1.2. It is guaranteed that admits a strongly stable matching, and Algorithm 4 returns one, say . If there is a -subinstance that admits no strongly stable matching, we conclude that also admits none. If all the -subinstances admit a stable matching, then their union plus is a strongly stable matching of . In Section 4.1.3, we give the whole algorithm and show its correctness.

#### 4.1.1 Notation and Shrinking Operation for Hrrc-instances

To simplify the description, we introduce two symbols, and .

###### Definition 4

Let be an instance of HRRC. For an agent , we define to be the set of agents that are acceptable to . For , we define to be the set of residents that are acceptable to all hospitals in .

We then introduce an operation called shrinking. Given an instance of HRRC, it reduces redundant hospital capacity without changing the set of strongly stable matchings of the instance.

###### Definition 5

Let be an instance of HRRC. Let be a mapping defined by . Then, an instance of HRRC is called a shrinked instance of . This operation is denoted by . That is, we write .

###### Lemma 1

Given an HRRC-instance , is a strongly stable matching of if and only if is a strongly stable matching of .

• Let be an HRRC-instance and be a shrinked instance of . First, suppose that is a strongly stable matching of . Since and for any , by the definition of , for any . Thus, is a matching of . Further, since and have the same regional caps and is feasible in , is also feasible in . Let be any BP for in (if any). Since and have the same preference lists and for any , is also a BP for in . Since is strongly stable in , satisfies neither condition (i) nor (ii) of Definition 3 in . This is also true in , since and have the same preference lists and regional caps. Then, is not an SBP for in . Thus, is also a strongly stable matching of .

Conversely, suppose that is a strongly stable matching of . Since the operation only reduces the capacity of hospitals, it is straightforward to verify that is also a feasible matching of . Let be any BP for in (if any). Then, is unassigned or prefers to . There are two cases for : , or there exists such that . In the former case, also holds since . By the definition of , we have , and hence blocks in . In the latter case, also holds in since and have the same preference lists. Therefore, blocks in . Thus, in either case, blocks in . Since is strongly stable in , satisfies neither condition (i) nor (ii) of Definition 3 in . This is also true in , since and have the same preference lists and regional caps. Then, is not an SBP for in . Thus, is also a strongly stable matching of .

#### 4.1.2 Algorithm for (2×2)-free Subinstances

Here we propose an algorithm to solve -free subinstances. Before describing the algorithm, we introduce a property of HR, which will be used in the correctness proof. In HR, each hospital is assigned the same number of residents in all the stable matchings [Rot84, GS85, Rot86]. The following corollary, which can be easily derived from the proof of Lemma 9 in [HIM16], states how the number of assigned residents changes if the capacity of a hospital is slightly decreased.

###### Corollary 4

Let be an instance of HR, be the set of hospitals, and be any hospital with positive capacity. Let be equivalent to except that only the capacity of is decreased by . For each , let be a stable matching of . Then, (i) , and (ii) for any , .

Now, the algorithm is shown in Algorithm 4. It accepts an HRRC-instance that satisfies all of the following properties: is disjoint; for any , ; for any , ; for any , ; for any such that , ; and for any , . Note that a region such that and corresponds to a -subinstance in a given instance. Hence if there is no -subinstance, for any such that , is guaranteed.

Algorithm 4 finds a stable matching by using RGS algorithm. As long as the output stable matching is infeasible, it chooses one region whose regional cap is broken, chooses one hospital in it, and reduces its capacity by one. When a feasible matching is found, Algorithm 4 outputs it.