Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Idea: Given an instance of StableMatching and a match determine whether the match is stable and if not give
  2. one instability.
  3. Input Format: The input file will be called input1.txt and be in the same directory as the java and class files.
  4. Line 0 will be a single integer n, the number of men (or women). Lines 1 to n will be the preferences of the n men
  5. where each line is a space seperated permutation of {1, 2, . . . , n}. Lines n + 1 to n + n will be the preferences of
  6. the n women where each line is a space seperated permutation of {1, 2, . . . , n}. Line 2n + 1 will be a permutation
  7. of {1, 2, 3, . . . , n} which represents a matching. In particular, the ith item in the permutation is the number of the
  8. woman with which man i is matched.
  9. Output: Yes (if the match is stable) or No and an ordered pair representing an instability (if the match is unstable).
  10. Examples: If there were 2 men (and women), both men prefered woman 1, both women prefered man 1, and you
  11. wanted to check the match M1-W1, M2-W2 then the input would be
  12. 2
  13. 1 2
  14. 1 2
  15. 1 2
  16. 1 2
  17. 1 2
  18. and the output would be
  19. Yes
  20. because the matching is stable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement